Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken string.matchAll behavior after compilation #10134

Open
mrtnzlml opened this issue Jun 26, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@mrtnzlml
Copy link
Contributor

commented Jun 26, 2019

Bug Report

Current Behavior
Output code after transpilation doesn't work as expected. It returns undefined capture groups. See below.

Input Code
I took last example from here: https://v8.dev/features/string-matchall (repl)

const string = 'Favorite GitHub repos: tc39/ecma262 v8/v8.dev';
const regex = /\b(?<owner>[a-z0-9]+)\/(?<repo>[a-z0-9\.]+)\b/g;
for (const match of string.matchAll(regex)) {
  console.log(`${match[0]} at ${match.index} with '${match.input}'`);
  console.log(`→ owner: ${match.groups.owner}`);
  console.log(`→ repo: ${match.groups.repo}`);
}

It returns this when you run it just like this before Babel:

tc39/ecma262 at 23 with 'Favorite GitHub repos: tc39/ecma262 v8/v8.dev'
→ owner: tc39
→ repo: ecma262
v8/v8.dev at 36 with 'Favorite GitHub repos: tc39/ecma262 v8/v8.dev'
→ owner: v8
→ repo: v8.dev

Expected behavior/code
It should return the same output. Unfortunately, it returns this:

tc39/ecma262 at 23 with 'Favorite GitHub repos: tc39/ecma262 v8/v8.dev'
→ owner: undefined
→ repo: undefined
v8/v8.dev at 36 with 'Favorite GitHub repos: tc39/ecma262 v8/v8.dev'
→ owner: undefined
→ repo: undefined

(capturing groups got lost and return undefined values after translation)

Babel Configuration (.babelrc, package.json, cli command)

Reproducible in REPL with env preset and Node.js <9 (latest Node.js are broken in REPL).

@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Jun 26, 2019

Hey @mrtnzlml! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

kiwicom-github-bot added a commit to kiwicom/babel-preset-kiwicom that referenced this issue Jun 26, 2019

Babel preset: add broken test for issue 10134
See: babel/babel#10134

kiwicom-source-id: 12b133b3f36f72272aaa57811d18c7c2f6da6ed7

@tanhauhau tanhauhau referenced a pull request that will close this issue Jun 27, 2019

Open

fix capturing group for matchAll #10136

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.