Skip to content

Commit

Permalink
bytecode: Reject type names that don't evaluate correctly
Browse files Browse the repository at this point in the history
When a type evaluate as an error, do not store it in the target.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
  • Loading branch information
c3d committed Dec 29, 2021
1 parent f013ef4 commit 6bbde9e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bytecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit 6bbde9e

Please sign in to comment.