jsx / JSX

JSX - a faster, safer, easier JavaScript
http://jsx.github.io/
MIT License
1.46k stars 102 forks source link

Can users set strict mode in JSX? #324

Open yosuke-furukawa opened 10 years ago

yosuke-furukawa commented 10 years ago

I published a JSX module implements Object.freeze in yesterday.

https://github.com/yosuke-furukawa/freezer.jsx

However, Object.freeze do not throw exception in non-strict mode.

I would like to know how to set 'use strict' in JSX.

yosuke-furukawa commented 10 years ago

I have found a way to set strict mode in node.js.

--use_strict option is enabled in node.js runtime. If this option enable, the program become strict mode inspite of "use strict"; or not.

kazuho commented 10 years ago

Thank you for your contribution. Did the generated code run under strict mode?

IMO we should better always set use strict in the generated code, but I am not confident enough that it would not introduce any compatibility problem nor have any impact on execution speed.

kazuho commented 10 years ago

FYI The code generated by JSX is not compatible with strict mode. You can see some tests failing in branch: https://github.com/jsx/JSX/tree/kazuho/experiments/use-strict

nyuichi commented 10 years ago

@kazuho

As tested your branch on my environment (v0.11.11), I don't see any warning or test failures. Which test case did you see failing?

kazuho commented 10 years ago

@yosuke-furukawa @wasabiz

Sorry.

You need to run JSX_RUNJS='node --use_strict' make test on the aforementioned branch (kazuho/experiments/use-strict).

I have fixed subtle issues re compatibility with strict mode, but there are still problems.