boa icon indicating copy to clipboard operation
boa copied to clipboard

RegExp /=/ not parsed as such in certain locations

Open dapper-gh opened this issue 1 year ago • 0 comments

Describe the bug The code () => /=/ (and certain other uses of the RegExp literal /=/) raises a SyntaxError.

To Reproduce Execute the following JavaScript:

() => /=/

Expected behavior This code should be parsed as an arrow function expression with no arguments that returns a RegExp that matches the character =. (semantically equivalent to () => new RegExp("="))

Build environment (please complete the following information):

  • OS: Artix Linux
  • Version: rolling
  • Target triple: x86_64-unknown-linux-gnu
  • Rustc version: rustc 1.72.1 (d5c2e9c34 2023-09-13)

Additional context Notably, return /=/ inside of an arrow function errors, but not inside of a function function.

() => {return /=/} // error
(function() {return /=/}) // fine!

Other uses of the literal /=/ that error include:

let a = 5; /=/; // should construct RegExp and set a to 5, instead errors
+/=/ // should evaluate to NaN
class A extends /=/ {} // should error out because /=/ is not a constructor, not because of syntax

dapper-gh avatar Sep 30 '23 22:09 dapper-gh