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

'\xxx' not recognized #4

Open
837951602 opened this issue Feb 8, 2017 · 3 comments
Open

'\xxx' not recognized #4

837951602 opened this issue Feb 8, 2017 · 3 comments

Comments

@837951602
Copy link
Contributor

'\040' 28903 bytes as Function("return '\040'")() instead of directly describe char32(space)?

@fasttime
Copy link
Owner

fasttime commented Feb 8, 2017

Thanks for reporting this. The reason why JScrewIt does not parse octal escape sequences is that they are illegal in strict mode. For example, ES6 modules are always strict mode code. A script containing the literal '\040' must produce a syntax error when it is loaded as a module, but this would not happen if the escape sequence were resolved by the parser and encoded like an unescaped character.

I think a good solution is adding a feature to explicitly enable octal escape sequences and legacy octal numbers. In the UI, this would be enabled in all compatibility modes except maximum compatibility and custom compatibility when the option "Generate strict mode code" is checked.

@837951602
Copy link
Contributor Author

A feature "NON_STRICT" containing "INCR_CHAR" and "LEGAL_OCT" and etc?

@fasttime
Copy link
Owner

There should be a feature "LEGACY_OCT". A combined feature "NON_STRICT" wouldn't be particularly useful because both "INCR_CHAR" and "LEGACY_OCT" would be already available in all engines.

The point is that some strict mode restrictions are not properly enforced everywhere: Node.js <= 4 forbids legacy octals in strict mode but allows increments on chars; IE 9 in strict mode allows both.

Anyway there is already a strict mode environment, it's called "forced-strict-mode". This is now used to remove "INCR_CHAR" in strict mode from some engines but not from others (precisely from engines with the attribute "char-increment-restriction"). The same method should be used for legacy octals when the new feature is introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants