You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While experimenting with a solution that uses javy, I happened to include the camelcase package. When attempting to build, I get the error below.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Uncaught SyntaxError: invalid escape sequence in regular expression
at RegExp (native)
at <eval> (<input>:10)
at ./node_modules/camelcase/index.js (script.js:39)
at __webpack_require__ (script.js:63)
at <eval> (<input>:2)
at ./src/index.js (script.js:29)
at __webpack_require__ (script.js:63)
at <anonymous> (script.js:115)
at <anonymous> (script.js:118)
at webpackUniversalModuleDefinition (script.js:15)
at <eval> (script.js:120)
', crates/core/src/lib.rs:35:61
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: the `wizer.initialize` function trapped
Caused by:
wasm trap: wasm `unreachable` instruction executed
wasm backtrace:
0: 0xcb9d9 - <unknown>!__rust_start_panic
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable to may show more debugging information
Error: Couldn't create wasm from input
Reproduction here, I was able to isolate the issue to the following lines in camelcase:
const IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
const SEPARATORS = /[_.\- ]+/;
const LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);
// THIS LINE APPEARS TO BE THE ISSUE
const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, 'gu');
Not sure what the exact issue is, or how common it might be in other code.
The text was updated successfully, but these errors were encountered:
Good catch. I spent some time investigating this and I was able to the get to the bottom of the issue: passing the unicode flag to a regular expression puts the regular expression engine in "strict mode", in plain words this means that some escape sequences, such as \-, \: will be considered erroneous (ref); in that sense the error can be considered expected, what's unexpected here is the behaviour across engines, in V8 for example, using the RegExp constructor and passing the u flag, doesn't cause an error, but when constructing the regular expression through a literal with an invalid escape sequence, the error appears:
varr=newRegExp("\-",'u');console.log(r)// /-/u => the escape was removed// vs /\:/u// Results in Invalid regular expression: /\:/: Invalid escape
While experimenting with a solution that uses
javy
, I happened to include thecamelcase
package. When attempting to build, I get the error below.Reproduction here, I was able to isolate the issue to the following lines in
camelcase
:Not sure what the exact issue is, or how common it might be in other code.
The text was updated successfully, but these errors were encountered: