mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 23:12:19 +00:00
Improve error message for accessing method like a field (#253)
This commit is contained in:
parent
3605630747
commit
ef2c0c623e
@ -6727,6 +6727,13 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
case ElementKind.PROPERTY: {// instance property (here: getter)
|
case ElementKind.PROPERTY: {// instance property (here: getter)
|
||||||
return this.compileGetter(<Property>target, propertyAccess);
|
return this.compileGetter(<Property>target, propertyAccess);
|
||||||
}
|
}
|
||||||
|
case ElementKind.FUNCTION_PROTOTYPE: {
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set,
|
||||||
|
propertyAccess.range, (<FunctionPrototype>target).simpleName
|
||||||
|
);
|
||||||
|
return module.createUnreachable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
@ -28,6 +28,7 @@ export enum DiagnosticCode {
|
|||||||
Optional_parameter_must_have_an_initializer = 215,
|
Optional_parameter_must_have_an_initializer = 215,
|
||||||
Constructor_of_class_0_must_not_require_any_arguments = 216,
|
Constructor_of_class_0_must_not_require_any_arguments = 216,
|
||||||
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,
|
||||||
Unterminated_string_literal = 1002,
|
Unterminated_string_literal = 1002,
|
||||||
Identifier_expected = 1003,
|
Identifier_expected = 1003,
|
||||||
_0_expected = 1005,
|
_0_expected = 1005,
|
||||||
@ -147,6 +148,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
|
|||||||
case 215: return "Optional parameter must have an initializer.";
|
case 215: return "Optional parameter must have an initializer.";
|
||||||
case 216: return "Constructor of class '{0}' must not require any arguments.";
|
case 216: return "Constructor of class '{0}' must not require any arguments.";
|
||||||
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 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.";
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"Optional parameter must have an initializer.": 215,
|
"Optional parameter must have an initializer.": 215,
|
||||||
"Constructor of class '{0}' must not require any arguments.": 216,
|
"Constructor of class '{0}' must not require any arguments.": 216,
|
||||||
"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,
|
||||||
|
|
||||||
"Unterminated string literal.": 1002,
|
"Unterminated string literal.": 1002,
|
||||||
"Identifier expected.": 1003,
|
"Identifier expected.": 1003,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user