prepack
prepack copied to clipboard
Lint against redeclared variables
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.
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.
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?
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
Fixed conflicts from master. Let's try and get this one in if possible :)
@trueadm You'll get it in? I forgot why we didn't last time.
@gaearon Yep, the tests pass now.