Skip to content

Change assertion failure to unreachable statement #1205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ export class Compiler extends DiagnosticEmitter {
/** Compiles a global variable. */
compileGlobal(global: Global): bool {
if (global.is(CommonFlags.COMPILED)) return true;
global.set(CommonFlags.COMPILED);

var module = this.module;
var initExpr: ExpressionRef = 0;
Expand Down Expand Up @@ -995,6 +994,7 @@ export class Compiler extends DiagnosticEmitter {
if (global.is(CommonFlags.AMBIENT) && global.hasDecorator(DecoratorFlags.BUILTIN)) {
if (global.internalName == BuiltinNames.heap_base) this.runtimeFeatures |= RuntimeFeatures.HEAP;
else if (global.internalName == BuiltinNames.rtti_base) this.runtimeFeatures |= RuntimeFeatures.RTTI;
global.set(CommonFlags.COMPILED);
return true;
}

Expand Down Expand Up @@ -1140,6 +1140,7 @@ export class Compiler extends DiagnosticEmitter {
} else if (!isDeclaredInline) { // compile normally
module.addGlobal(internalName, nativeType, !isDeclaredConstant, initExpr);
}
global.set(CommonFlags.COMPILED);
return true;
}

Expand Down Expand Up @@ -1876,7 +1877,9 @@ export class Compiler extends DiagnosticEmitter {
if (
!element.is(CommonFlags.AMBIENT) && // delay imports
!element.hasDecorator(DecoratorFlags.LAZY)
) this.compileGlobal(<Global>element);
) {
if (this.compileGlobal(<Global>element)) this.module.unreachable();
}
}
}
break;
Expand Down Expand Up @@ -7915,7 +7918,6 @@ export class Compiler extends DiagnosticEmitter {
return module.unreachable();
}
let globalType = global.type;
assert(globalType != Type.void);
if (global.is(CommonFlags.INLINED)) {
return this.compileInlineConstant(global, contextualType, constraints);
}
Expand Down