Skip to content

Commit

Permalink
fix: Diagnose not yet implemented 'in' operator (#2629)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Jan 22, 2023
1 parent 4535263 commit 7ccadf0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/compiler.ts
Expand Up @@ -4662,6 +4662,14 @@ export class Compiler extends DiagnosticEmitter {
}
break;
}
case Token.In: {
this.error(
DiagnosticCode.Not_implemented_0,
expression.range, "'in' operator"
);
this.currentType = Type.bool;
return module.unreachable();
}
default: {
assert(false);
expr = this.module.unreachable();
Expand Down
3 changes: 2 additions & 1 deletion src/parser.ts
Expand Up @@ -4311,7 +4311,8 @@ export class Parser extends DiagnosticEmitter {
case Token.Bar:
case Token.Caret:
case Token.Ampersand_Ampersand:
case Token.Bar_Bar: {
case Token.Bar_Bar:
case Token.In: {
let next = this.parseExpression(tn, nextPrecedence + 1);
if (!next) return null;
expr = Node.createBinaryExpression(token, expr, next, tn.range(startPos, tn.pos));
Expand Down
6 changes: 6 additions & 0 deletions src/resolver.ts
Expand Up @@ -2054,6 +2054,12 @@ export class Resolver extends DiagnosticEmitter {
return Type.bool;
}

// in operator

case Token.In: {
return Type.bool;
}

// arithmetics: result is common type of LHS and RHS, preferring overloads

case Token.Plus:
Expand Down
6 changes: 6 additions & 0 deletions tests/compiler/in.json
@@ -0,0 +1,6 @@
{
"stderr": [
"AS100: Not implemented: 'in' operator", "\"log\" in console",
"EOF"
]
}
3 changes: 3 additions & 0 deletions tests/compiler/in.ts
@@ -0,0 +1,3 @@
"log" in console;

ERROR("EOF");

0 comments on commit 7ccadf0

Please sign in to comment.