Page MenuHomePhabricator

Arrow functions break the syntax parser in the code editor
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

Note that the above is ES6-compatible code (JavaScript from 2015).

What happens?:
There are a few problems, probably related:

  • Try to fold hide function -> you should not be able to see the // broken fold ^ comment (but you do see it).
  • In filehide function this part seem to start a comment: str.replace(/<gallery/gi, (a, options, content) => { (parser works fine when you change the arrow function to function(a, options, content))
  • In show function the comment state is reverted, but starts again after str.replace(/<<<([0-9]+)>>>/g, (a, i) => {.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Classes seem to suggest Ace editor is used for code. I tried Ace demo editor and it worked fine. An upgrade is perhaps required?

Event Timeline

Pppery renamed this task from Arrow functions brake the syntax parser in the code editor to Arrow functions break the syntax parser in the code editor.Sat, Dec 28, 12:18 AM
Pppery added a project: CodeEditor.

We're on Ace 1.32.7 (from March 2024) which obviously supports ES6. There could be a subtle bug in that version as the issue goes away on upgrading. A quick skim of the changelog didn't turn up anything relevant though.

Change #1107051 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/extensions/CodeEditor@master] Upgrade Ace from 1.32.7 to 1.37.1

https://gerrit.wikimedia.org/r/1107051

Confirmed on archived ACE version:
https://web.archive.org/web/20240324151011/https://ace.c9.io/

So it was just an ACE issue. Interesting.

Change #1107051 merged by jenkins-bot:

[mediawiki/extensions/CodeEditor@master] Upgrade Ace from 1.32.7 to 1.37.1

https://gerrit.wikimedia.org/r/1107051

SD0001 claimed this task.

Change #1108443 had a related patch set uploaded (by Jforrester; author: Jforrester):

[mediawiki/extensions/WikiLambda@master] Upgrade Ace from 1.32.7 to 1.37.1

https://gerrit.wikimedia.org/r/1108443

Change #1108443 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Upgrade Ace from 1.32.7 to 1.37.1

https://gerrit.wikimedia.org/r/1108443