From 332592a54762cc2712161bd6b50388aefdd8e9b0 Mon Sep 17 00:00:00 2001 From: Christophe de Dinechin Date: Fri, 2 Apr 2021 08:19:32 +0200 Subject: [PATCH] bytecode: Reject type names that don't evaluate correctly When a type evaluate as an error, do not store it in the target. Signed-off-by: Christophe de Dinechin --- src/bytecode.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bytecode.cpp b/src/bytecode.cpp index 26a1c8dda..dd7f8209b 100644 --- a/src/bytecode.cpp +++ b/src/bytecode.cpp @@ -2149,6 +2149,8 @@ strength BytecodeBindings::Do(Infix *what) // Need to evaluate the type on the right Tree_p want = EvaluateType(what->right); + if (IsError(want)) + return Failed(); what->right = want; // Need to match the left part with the converted value @@ -2347,6 +2349,8 @@ inline Context::LookupMode lookupMode(Bytecode *bytecode) } +static void debug(Tree *expr, Tree *decl) {} + static Tree *lookupCandidate(Scope *evalScope, Scope *declScope, Tree *expr, @@ -2362,6 +2366,12 @@ static Tree *lookupCandidate(Scope *evalScope, Tree *pattern = decl->Pattern(); XL_ASSERT(bindings.Self() == expr); +if (Prefix *prefix = expr->AsPrefix()) + if (Name *name = prefix->left->AsName()) + if (name->value == "write") + if (Text *text = prefix->right->AsText()) + debug(expr, decl); + // Add bytecode to check argument against parameters and create locals Bytecode::Attempt attempt(bytecode); bindings.Candidate(decl, evalScope, declScope);