Better error message for super when not using an object method (#6754)

This commit is contained in:
Raja Sekar 2017-11-16 08:59:46 +05:30 committed by Brian Ng
parent 48906604f2
commit 63397d0aad
5 changed files with 18 additions and 5 deletions

View File

@ -648,7 +648,10 @@ export default class ExpressionParser extends LValParser {
!this.state.inClassProperty && !this.state.inClassProperty &&
!this.options.allowSuperOutsideMethod !this.options.allowSuperOutsideMethod
) { ) {
this.raise(this.state.start, "'super' outside of function or class"); this.raise(
this.state.start,
"super is only allowed in object methods and classes",
);
} }
node = this.startNode(); node = this.startNode();

View File

@ -0,0 +1,7 @@
Object.create({}, {
foo: {
get: function(){
return super.foo;
}
}
});

View File

@ -0,0 +1,3 @@
{
"throws": "super is only allowed in object methods and classes (4:13)"
}

View File

@ -1,3 +1,3 @@
{ {
"throws": "'super' outside of function or class (1:0)" "throws": "super is only allowed in object methods and classes (1:0)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "'super' outside of function or class (1:8)" "throws": "super is only allowed in object methods and classes (1:8)"
} }