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

ERROR: c.has is not a function when using unsafe compression on __defineSetter__ used as global #524

Closed
m4rw3r opened this issue Nov 28, 2019 · 2 comments
Labels

Comments

@m4rw3r
Copy link

m4rw3r commented Nov 28, 2019

Bug report or Feature request?

Bug

Version (complete output of terser -V or specific git commit)

Both 4.4.0 and b66fd6b

Complete CLI command or minify() options used

terser test.js -c unsafe

terser input

__defineSetter__.call(null, key, function () { /* empty */ });

terser output or error

ERROR: c.has is not a function
    at AST_Dot.thedef [as _eval] (terser-master/lib/compress/index.js:3029:72)
    at AST_Dot.evaluate (terser-master/lib/compress/index.js:2793:24)
    at flatten_object (terser-master/lib/compress/index.js:6940:20)
    at AST_Dot.OPTIMIZED [as optimize] (terser-master/lib/compress/index.js:444:28)
    at Qn.this [as before] (terser-master/lib/compress/index.js:415:42)
    at AST_Dot.transform (terser-master/lib/transform.js:94:20)
    at do_list (terser-master/lib/transform.js:214:21)
    at Qn.node [as before] (terser-master/lib/compress/index.js:416:13)
    at AST_Call.transform (terser-master/lib/transform.js:94:20)
    at body (terser-master/lib/transform.js:121:10)

Expected result

__defineSetter__.call(null,key,(function(){}));
@fabiosantoscode
Copy link
Collaborator

Nice catch! Thanks for this report!

@fabiosantoscode
Copy link
Collaborator

fabiosantoscode commented Dec 1, 2019

This is a very cool bug, and a nice reminder of why we should use maps instead of objects. Internally Terser has found a property called __defineSetter__ within an object, and is happily trying to use it as if it was a set, but it's a function. Fix coming up soon.

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

No branches or pull requests

2 participants