mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Emit a better error when expecting a compile-time constant, fixes #222
This commit is contained in:
parent
9a8ed25b19
commit
47b2f33564
@ -3444,7 +3444,7 @@ function evaluateConstantOffset(compiler: Compiler, expression: Expression): i32
|
|||||||
(value = getConstValueI64Low(expr)) < 0
|
(value = getConstValueI64Low(expr)) < 0
|
||||||
) {
|
) {
|
||||||
compiler.error(
|
compiler.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Expression_must_be_a_compile_time_constant,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
value = -1;
|
value = -1;
|
||||||
@ -3457,7 +3457,7 @@ function evaluateConstantOffset(compiler: Compiler, expression: Expression): i32
|
|||||||
(value = getConstValueI32(expr)) < 0
|
(value = getConstValueI32(expr)) < 0
|
||||||
) {
|
) {
|
||||||
compiler.error(
|
compiler.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Expression_must_be_a_compile_time_constant,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
value = -1;
|
value = -1;
|
||||||
|
@ -30,6 +30,7 @@ export enum DiagnosticCode {
|
|||||||
Function_0_cannot_be_inlined_into_itself = 217,
|
Function_0_cannot_be_inlined_into_itself = 217,
|
||||||
Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set = 218,
|
Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set = 218,
|
||||||
Optional_properties_are_not_supported = 219,
|
Optional_properties_are_not_supported = 219,
|
||||||
|
Expression_must_be_a_compile_time_constant = 220,
|
||||||
Unterminated_string_literal = 1002,
|
Unterminated_string_literal = 1002,
|
||||||
Identifier_expected = 1003,
|
Identifier_expected = 1003,
|
||||||
_0_expected = 1005,
|
_0_expected = 1005,
|
||||||
@ -159,6 +160,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
|
|||||||
case 217: return "Function '{0}' cannot be inlined into itself.";
|
case 217: return "Function '{0}' cannot be inlined into itself.";
|
||||||
case 218: return "Cannot access method '{0}' without calling it as it requires 'this' to be set.";
|
case 218: return "Cannot access method '{0}' without calling it as it requires 'this' to be set.";
|
||||||
case 219: return "Optional properties are not supported.";
|
case 219: return "Optional properties are not supported.";
|
||||||
|
case 220: return "Expression must be a compile-time constant.";
|
||||||
case 1002: return "Unterminated string literal.";
|
case 1002: return "Unterminated string literal.";
|
||||||
case 1003: return "Identifier expected.";
|
case 1003: return "Identifier expected.";
|
||||||
case 1005: return "'{0}' expected.";
|
case 1005: return "'{0}' expected.";
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
"Function '{0}' cannot be inlined into itself.": 217,
|
"Function '{0}' cannot be inlined into itself.": 217,
|
||||||
"Cannot access method '{0}' without calling it as it requires 'this' to be set.": 218,
|
"Cannot access method '{0}' without calling it as it requires 'this' to be set.": 218,
|
||||||
"Optional properties are not supported.": 219,
|
"Optional properties are not supported.": 219,
|
||||||
|
"Expression must be a compile-time constant.": 220,
|
||||||
|
|
||||||
"Unterminated string literal.": 1002,
|
"Unterminated string literal.": 1002,
|
||||||
"Identifier expected.": 1003,
|
"Identifier expected.": 1003,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user