Skip to content

Commit 4dc6567

Browse files
authored
fix: Emit a diagnostic when an expression refers to a static element (#1661)
1 parent 5981995 commit 4dc6567

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/compiler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7682,7 +7682,10 @@ export class Compiler extends DiagnosticEmitter {
76827682
: module.i32(i64_low(offset));
76837683
}
76847684
}
7685-
assert(false);
7685+
this.error(
7686+
DiagnosticCode.Expression_refers_to_a_static_element_that_does_not_compile_to_a_value_at_runtime,
7687+
expression.range
7688+
);
76867689
return this.module.unreachable();
76877690
}
76887691

src/diagnosticMessages.generated.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export enum DiagnosticCode {
5050
A_class_with_a_constructor_explicitly_returning_something_else_than_this_must_be_final = 231,
5151
Exported_generic_function_or_class_has_no_concrete_instances = 232,
5252
Property_0_is_always_assigned_before_being_used = 233,
53+
Expression_refers_to_a_static_element_that_does_not_compile_to_a_value_at_runtime = 234,
5354
Importing_the_table_disables_some_indirect_call_optimizations = 901,
5455
Exporting_the_table_disables_some_indirect_call_optimizations = 902,
5556
Expression_compiles_to_a_dynamic_check_at_runtime = 903,
@@ -228,6 +229,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
228229
case 231: return "A class with a constructor explicitly returning something else than 'this' must be '@final'.";
229230
case 232: return "Exported generic function or class has no concrete instances.";
230231
case 233: return "Property '{0}' is always assigned before being used.";
232+
case 234: return "Expression refers to a static element that does not compile to a value at runtime.";
231233
case 901: return "Importing the table disables some indirect call optimizations.";
232234
case 902: return "Exporting the table disables some indirect call optimizations.";
233235
case 903: return "Expression compiles to a dynamic check at runtime.";

src/diagnosticMessages.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"A class with a constructor explicitly returning something else than 'this' must be '@final'.": 231,
4444
"Exported generic function or class has no concrete instances.": 232,
4545
"Property '{0}' is always assigned before being used.": 233,
46+
"Expression refers to a static element that does not compile to a value at runtime.": 234,
4647

4748
"Importing the table disables some indirect call optimizations.": 901,
4849
"Exporting the table disables some indirect call optimizations.": 902,

0 commit comments

Comments
 (0)