Skip to content

fix corner case in unsafe evaluate #4932

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

Merged
merged 1 commit into from
May 14, 2021
Merged

Conversation

alexlamsl
Copy link
Collaborator

fixes #4931

@alexlamsl alexlamsl merged commit 7576048 into mishoo:master May 14, 2021
@alexlamsl alexlamsl deleted the issue-4931 branch May 14, 2021 14:51
@alexlamsl
Copy link
Collaborator Author

@kzc TIL:

$ node -v
v8.17.0

$ echo 'for ({} of [ null ]);' | node
[stdin]:1
for ({} of [ null ]);
     ^

TypeError: Cannot destructure 'undefined' or 'null'.
    at [stdin]:1:6

$ echo 'for (var {} of [ null ]);' | node
[stdin]:1
for (var {} of [ null ]);
         ^

TypeError: Cannot destructure 'undefined' or 'null'.
    at [stdin]:1:1
$ node -v
v16.0.0

$ echo 'for ({} of [ null ]);' | node
[stdin]:1
for ({} of [ null ]);
     ^

TypeError: Cannot read property 'undefined' of null
    at [stdin]:1:6

$ echo 'for (var {} of [ null ]);' | node
[stdin]:1
for (var {} of [ null ]);
          ^

TypeError: Cannot destructure '.for' as it is null.
    at [stdin]:1:10

That last one seems to expose internal plumbing of v8 🤔

@kzc
Copy link
Contributor

kzc commented May 14, 2021

That last one seems to expose internal plumbing of v8 🤔

It does indeed.

For that matter, what is the 'undefined' property being referred to in TypeError: Cannot read property 'undefined' of null? Again, the node 8 error made more sense: TypeError: Cannot destructure 'undefined' or 'null'.. More exposed plumbing?

@alexlamsl
Copy link
Collaborator Author

alexlamsl commented May 14, 2021

Now try and make sense out of this one:
https://github.com/mishoo/UglifyJS/runs/2587286297?check_suite_focus=true#step:3:4119

$ node -v
v8.17.0

$ echo 'null[{} = 0]++' | node
[stdin]:1
null[{} = 0]++
        ^

TypeError: Cannot read property '0' of null
    at [stdin]:1:9
$ node -v
v16.0.0\x64

$ echo 'null[{} = 0]++' | node
[stdin]:1
null[{} = 0]++
          ^

TypeError: Cannot destructure '0' as it is null.
    at [stdin]:1:6

@kzc
Copy link
Contributor

kzc commented May 15, 2021

Good one.

Since destructuring is difficult to implement it ought to be difficult to explain too.

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

Successfully merging this pull request may close these issues.

ufuzz failure
2 participants