Bug 155491 - [ES6] Arrow function syntax. Update syntax error text 'super is only valid inside functions' to more suitable
Summary: [ES6] Arrow function syntax. Update syntax error text 'super is only valid in...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 153864
Blocks: 140855
  Show dependency treegraph
 
Reported: 2016-03-15 07:03 PDT by GSkachkov
Modified: 2016-03-20 00:43 PDT (History)
5 users (show)

See Also:


Attachments
Patch (12.97 KB, patch)
2016-03-19 08:36 PDT, GSkachkov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description GSkachkov 2016-03-15 07:03:14 PDT
After landing  https://bugs.webkit.org/show_bug.cgi?id=153864 the patch we need to fix Syntax error message. 
It is recommended by Saam Barati to use new message "super is only valid inside functions or 'eval' inside a function".
Comment 1 GSkachkov 2016-03-18 12:54:08 PDT
The same for new.target "new.target is only valid inside functions" -> "new.target is only valid inside functions or 'eval' inside a function"
Comment 2 GSkachkov 2016-03-19 08:36:39 PDT
Created attachment 274515 [details]
Patch
Comment 3 Saam Barati 2016-03-19 09:57:19 PDT
Comment on attachment 274515 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274515&action=review

> Source/JavaScriptCore/parser/Parser.cpp:3847
> +        semanticFailIfFalse(currentScope()->isFunction() || (scopeRef->isEvalContext() && scopeRef->expectedSuperBinding() == SuperBinding::Needed), "super is only valid inside functions or 'eval' inside a function");

I vote for this message:
"'super' is only valid inside a function or an 'eval' inside a function"

Do you know what we do when we have 'super' inside a function not in a class?
It looks like we accept that syntax. Do we throw a runtime error? Should that also
be a syntax error?

> Source/JavaScriptCore/tests/stress/generator-with-super.js:12
> +    //debug(error);

Remove
Comment 4 GSkachkov 2016-03-19 10:43:34 PDT
Comment on attachment 274515 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274515&action=review

>> Source/JavaScriptCore/parser/Parser.cpp:3847
>> +        semanticFailIfFalse(currentScope()->isFunction() || (scopeRef->isEvalContext() && scopeRef->expectedSuperBinding() == SuperBinding::Needed), "super is only valid inside functions or 'eval' inside a function");
> 
> I vote for this message:
> "'super' is only valid inside a function or an 'eval' inside a function"
> 
> Do you know what we do when we have 'super' inside a function not in a class?
> It looks like we accept that syntax. Do we throw a runtime error? Should that also
> be a syntax error?

OK. I'll change text message.

According to the super inside a function not in a class, we will have syntax error also We have additional check if current function is constructor or method of class:
http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/parser/Parser.cpp#L2078

>> Source/JavaScriptCore/tests/stress/generator-with-super.js:12
>> +    //debug(error);
> 
> Remove

Ups...
Comment 5 GSkachkov 2016-03-20 00:42:42 PDT
Comment on attachment 274515 [details]
Patch

Committed r198472: <http://trac.webkit.org/changeset/198472>
Comment 6 GSkachkov 2016-03-20 00:43:06 PDT
All reviewed patches have been landed.  Closing bug.