From 78e3be6ba321d46075ca0c775361bae39bce8ba4 Mon Sep 17 00:00:00 2001 From: ivanjermakov Date: Tue, 9 Apr 2024 15:53:25 +0200 Subject: [PATCH] Semantic: better method not found reporting --- src/semantic/instance.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/semantic/instance.ts b/src/semantic/instance.ts index 048289e2..d3f8ce85 100644 --- a/src/semantic/instance.ts +++ b/src/semantic/instance.ts @@ -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' @@ -104,7 +105,7 @@ 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_ = ( @@ -112,12 +113,13 @@ export const checkMethodCall_ = ( call: CallOp, methodVid: VirtualIdentifier, ctx: Context, - typeArgs?: Type[] + typeArgs?: Type[], + node: AstNode = 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 }