Skip to content

Commit 7f6c51c

Browse files
authored
fix: Emit a diagnostic when 'super' is used in a non-derived class (#1678)
1 parent 4400623 commit 7f6c51c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/compiler.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -6154,7 +6154,14 @@ export class Compiler extends DiagnosticEmitter {
61546154
let parent = assert(actualFunction.parent);
61556155
assert(parent.kind == ElementKind.CLASS);
61566156
let classInstance = <Class>parent;
6157-
let baseClassInstance = assert(classInstance.base);
6157+
let baseClassInstance = classInstance.base;
6158+
if (!baseClassInstance) {
6159+
this.error(
6160+
DiagnosticCode._super_can_only_be_referenced_in_a_derived_class,
6161+
expression.expression.range
6162+
);
6163+
return module.unreachable();
6164+
}
61586165
let thisLocal = assert(flow.lookupLocal(CommonNames.this_));
61596166
let nativeSizeType = this.options.nativeSizeType;
61606167

0 commit comments

Comments
 (0)