oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.83k stars 2.73k forks source link

Syntax error on octal escape in tagged template string #7540

Open kieran-osgood opened 10 months ago

kieran-osgood commented 10 months ago

What version of Bun is running?

1.0.15+b3bdf22eb

What platform is your computer?

Darwin 23.1.0 arm64 arm

What steps can reproduce the bug?

     // index.cjs / index.js
     const assert = require("assert")
     assert.equal(String.raw`/\1`.length, 3);

Then run it with bun index.cjs

What is the expected behavior?

Syntax is valid

➜ node index.cjs

What do you see instead?

➜ bun index.cjs
5 | assert.equal(String.raw`/\1`.length, 3);
                           ^
error: Syntax Error!!

Additional information

No response

paperdave commented 10 months ago
image

when it is not a template, it seems this is meant to be an error

obviously when it is a template, this is allowed, but it seems the parser is not aware of this.

cc @dylan-conway

paperdave commented 10 months ago

reduced reproduction, run bun build demo.ts

a`\1`
alexop1000 commented 1 month ago

Bump, causes issues in NextJS when importing a client-rendered component from a server-rendered one.

TechnologicNick commented 9 hours ago

Also fails on invalid \u0000 with less than 4 hexadecimals and \x00 with less than 2 hexadecimals.