Skip to content

Commit

Permalink
fix: Defuse flow assertion on invalid function expression (#2051)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Sep 10, 2021
1 parent b1a5b0f commit 1bf3120
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,6 @@ export class Flow {
canOverflow(expr: ExpressionRef, type: Type): bool {
// TODO: the following catches most common and a few uncommon cases, but there are additional
// opportunities here, obviously.
assert(type != Type.void);

// types other than i8, u8, i16, u16 and bool do not overflow
if (!type.isShortIntegerValue) return false;
Expand Down
8 changes: 8 additions & 0 deletions tests/compiler/function-expression-error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"asc_flags": [
],
"stderr": [
"TS1110: Type expected.", "missingReturnType",
"EOF"
]
}
5 changes: 5 additions & 0 deletions tests/compiler/function-expression-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// see: https://github.com/AssemblyScript/assemblyscript/issues/2036

const missingReturnType: u32 = (() => 42).index;

ERROR("EOF");

0 comments on commit 1bf3120

Please sign in to comment.