Skip to content

Commit

Permalink
Semantic: better method not found reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Apr 9, 2024
1 parent e154d94 commit 78e3be6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/semantic/instance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { checkCallArgs } from '.'
import { AstNode } from '../ast'
import { UnaryExpr } from '../ast/expr'
import { CallOp, MethodCallOp } from '../ast/op'
import { Name, Operand } from '../ast/operand'
Expand Down Expand Up @@ -104,20 +105,21 @@ export const checkMethodCall = (expr: UnaryExpr, mCall: MethodCallOp, ctx: Conte

const methodVid = { names: [...typeVid.names, mCall.name.value] }
const args = [expr.operand, ...mCall.call.args.map(a => a.expr)]
return checkMethodCall_(args, mCall.call, methodVid, ctx, mCall.typeArgs)
return checkMethodCall_(args, mCall.call, methodVid, ctx, mCall.typeArgs, mCall.name)
}

export const checkMethodCall_ = (
args: Operand[],
call: CallOp,
methodVid: VirtualIdentifier,
ctx: Context,
typeArgs?: Type[]
typeArgs?: Type[],
node: AstNode<any> = call
): VirtualType | undefined => {
const typeVid = vidFromScope(methodVid)
const ref = resolveVid(methodVid, ctx, ['method-def'])
if (!ref || ref.def.kind !== 'method-def') {
addError(ctx, notFoundError(ctx, call, vidToString(methodVid), 'method'))
addError(ctx, notFoundError(ctx, node ?? call, vidToString(methodVid), 'method'))
return
}

Expand Down

0 comments on commit 78e3be6

Please sign in to comment.