prepack icon indicating copy to clipboard operation
prepack copied to clipboard

Lint against redeclared variables

Open gaearon opened this issue 5 years ago • 6 comments

There was recently a regression that caused variables to get redeclared: https://github.com/facebook/prepack/pull/2255#issuecomment-405923183.

To catch issues like this, I'm introducing no-redeclare as an additional lint rule that runs on serializer tests. I'm also adding a way to disable individual lint warnings since there's a case where we intentionally test code that's not-so-great.

This is still not sufficient because we do emit redeclaring variables. So this PR is expected to fail the tests until these cases get fixed.

I don't know if it's a recent issue or not, but I think it needs fixing. So I'm sending this PR as the first step to surface these issues. Once they get fixed, we can merge this.

gaearon avatar Jul 18 '18 14:07 gaearon

It's an issue. It's likely because generators currently do not form a tree, but a DAG. Until that's fixed, redeclared variables are to be expected.

NTillmann avatar Jul 18 '18 14:07 NTillmann

Would it be useful to add lint suppression to known cases where it happens and hope to reduce them in the future? Or is it too non deterministic?

gaearon avatar Jul 18 '18 15:07 gaearon

It looks like this fails on a lot more tests then the regressed NestedConditions.js I added. I’m guessing for different reasons. Is this expected?

Not by me, but yes, seems like it's an unexpected existing flaw

gaearon avatar Jul 18 '18 18:07 gaearon

Fixed conflicts from master. Let's try and get this one in if possible :)

trueadm avatar Aug 31 '18 12:08 trueadm

@trueadm You'll get it in? I forgot why we didn't last time.

gaearon avatar Aug 31 '18 12:08 gaearon

@gaearon Yep, the tests pass now.

trueadm avatar Aug 31 '18 12:08 trueadm