Node: Inconsistent ordering for regex named capture groups in v12.11.0

Created on 8 Oct 2019  Â·  4Comments  Â·  Source: nodejs/node

node:v12.11.0

There is inconsistent ordering for named capture groups from v12.10.0 to v12.11.0. It appears that versions that came before v12.11.0 ordered the keys by the way they were ordered in the regular expression. v12.11.0 seems to sort the keys.

const r = /(?<BKey>.+)\s(?<AKey>.+)/;
const s = 'example string';
// node v12.10.0
r.exec(s).groups;
// { "BKey": "example", "AKey": "string" }
// node v12.11.0
r.exec(s).groups;
// { "AKey": "string", "BKey": "example" }
V8 Engine

Most helpful comment

All 4 comments

Interesting – my understand of the spec would indicate to me that the former behaviour is correct: https://tc39.es/ecma262/#sec-regexpbuiltinexec

/cc @nodejs/v8

Fixed upstream in https://crrev.com/c/1864829.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jmichae3 picture jmichae3  Â·  3Comments

Brekmister picture Brekmister  Â·  3Comments

stevenvachon picture stevenvachon  Â·  3Comments

fanjunzhi picture fanjunzhi  Â·  3Comments

vsemozhetbyt picture vsemozhetbyt  Â·  3Comments