Closed Bug 951622 Opened 10 years ago Closed 5 years ago

Pretty printing "let x = {};" and other ES6 syntax in Scratchpad results in broken code

Categories

(DevTools Graveyard :: Scratchpad, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: vporof, Unassigned)

References

Details

Pretty printer probably gets confused by the let. This might be a dupe of something.
We use acorn's lexer, which only supports <= ES5. This is dependent on acorn supporting ES6 and us upgrading acorn.
Hi, I want to work on this bug. So please can you assign this to me?
This is dependant on acorn[0] supporting ES6, so if you fix it upstream we will merge it.

[0] https://github.com/marijnh/acorn
Just to state the obvious: same happens for const.

Much to my surprise the code still works after I run pretty print and save.

When I open another file in scratchpad, then go back to the bady pretty printed file I can see "const " became "const" and now I also get the expected syntax error.

Perhaps some caching at work that will be nasty to debug: "hmmh, the file still worked when I last used it".
Pretty Print also doesn't respect "=>" which also refers to ES6: It turns code line
"let s = (play) => a.Game;" into
"lets = (play) = > a.Game;"
Please, mark this bug as DUPLICATE of bug 938203.
Flags: needinfo?(vporof)
Hi, I am interested in fixing this bug, can you please assign this bug to me?
Nick, do you know what the status is here?  Is this still a valid bug?  If so, Anup may need some mentoring.  If it's a dupe, let's close it.
Flags: needinfo?(nfitzgerald)
Flags: needinfo?(nfitzgerald)
Flags: needinfo?(vporof)
Acorn now supports ES6. This should be fixable.
(In reply to Phil Keeling from comment #10)
> Acorn now supports ES6. This should be fixable.
Awesome! We should update our version of acorn then.
Instructions can be found here: \devtools\shared\acorn\UPGRADING.md
Looks like our version is quite old: 0.11.1 while 2.6.2 is available.
See Also: → 1226810
Is this bug still valid? Can anyone help with mentoring for fixing this bug?
(In reply to Anup Kumar from comment #12)
> Is this bug still valid? Can anyone help with mentoring for fixing this bug?
Yes this is still valid (I tested it last week and it still occurs).
I think Nick should be able to help you (I've needinfo'd him now). If already have the repo cloned and the dev-environment set up, you can take a look at the file I mentioned in comment 11, it provides some instructions already.
Flags: needinfo?(nfitzgerald)
I have a pull request open for pretty-fast that bumps to the latest version: https://github.com/mozilla/pretty-fast/pull/12.  We will also need to coordinate an upgrade to tern (Bug 1226810) at the same time since it's using acorn as well.
The PR has been merged.
Flags: needinfo?(nfitzgerald)
Need to wait to upgrade tern (which also relies on latest acorn) in Bug 1226810before merging the new pretty-fast into m-c.
Depends on: 1226810
Passing { ecmaVersion: 6 } into the options in pretty-fast seems to fix this particular case.  Will need to file a PR against pretty-fast for that
Blocks: 965141
Scratchpad triage, filter on "ghostbusterzzz"
Priority: -- → P3
Same here with this code

```
const test = () => {
```

which renders

```
consttest = () = > {
```
Summary: Pretty printing "let x = {};" in Scratchpad results in "letx = { };" → Pretty printing "let x = {};" and other ES6 syntax in Scratchpad results in broken code
Product: Firefox → DevTools

Scratchpad was removed in Bug 1519103 (Firefox 72). You can check the alternative in https://wiki.developer.mozilla.org/en-US/docs/Tools/Deprecated_tools#Scratchpad .

The Scratchpad bug list was reviewed and I think this bug can be safely closed.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX
Product: DevTools → DevTools Graveyard
You need to log in before you can comment on or make changes to this bug.