diff --git a/src/compiler.ts b/src/compiler.ts index 495f670822..641fab4aec 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -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; @@ -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; } @@ -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; } @@ -1876,7 +1877,9 @@ export class Compiler extends DiagnosticEmitter { if ( !element.is(CommonFlags.AMBIENT) && // delay imports !element.hasDecorator(DecoratorFlags.LAZY) - ) this.compileGlobal(element); + ) { + if (this.compileGlobal(element)) this.module.unreachable(); + } } } break; @@ -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); }