Better error message for super when not using an object method (#6754)
This commit is contained in:
parent
48906604f2
commit
63397d0aad
@ -648,7 +648,10 @@ export default class ExpressionParser extends LValParser {
|
||||
!this.state.inClassProperty &&
|
||||
!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();
|
||||
|
||||
7
packages/babylon/test/fixtures/es2015/class-methods/direct-super-in-object-method/actual.js
vendored
Normal file
7
packages/babylon/test/fixtures/es2015/class-methods/direct-super-in-object-method/actual.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
Object.create({}, {
|
||||
foo: {
|
||||
get: function(){
|
||||
return super.foo;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "super is only allowed in object methods and classes (4:13)"
|
||||
}
|
||||
@ -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)"
|
||||
}
|
||||
@ -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)"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user