Improve error message for accessing method like a field (#253)

This commit is contained in:
Andy Hanson
2018-09-09 18:21:30 -07:00
committed by Daniel Wirtz
parent 3605630747
commit ef2c0c623e
3 changed files with 10 additions and 0 deletions

View File

@ -6727,6 +6727,13 @@ export class Compiler extends DiagnosticEmitter {
case ElementKind.PROPERTY: {// instance property (here: getter)
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(
DiagnosticCode.Operation_not_supported,