-
Notifications
You must be signed in to change notification settings - Fork 14
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
More precise lookup for string property of AstNameTy
#157
Conversation
Currently, with es2022, the following ReturnTypeMismatch happens with PerformEval
Why is that? In in step 28.a, the rhs in the below statement,
This is because body is the result of So body is not just any AST but specifically ScriptBody. But this is not handled properly in the current version of ESMeta. As I debugged the cause, the reason was because lookupAst was not implemented when the
So I copied the lookup logic for AstSingleTy and handled the AstNameTy case analogously. As a result, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define and use a helper function for the math
case.
previously, lookup of string property in AstNameTy did not work and just returned AstTopTy. For example, in es2022, there is a lookup of let body = script.ScriptBody And according to the [spec](https://tc39.es/ecma262/#prod-ScriptBody), this should evaluate to Ast[StatementList] but did not, causing imprecision in the analysis. This commit fixes the issue.
1649af9
to
7f85a8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slightly refactored your code before accepting the PR. Thanks!
AstNameTy
Previously, lookup of string property in AstNameTy did not work and just returned AstTopTy. For example, in es2022, there is a lookup of
let body = script.ScriptBody
in PerformEval
And according to the spec, this should evaluate to Ast[StatementList] but did not, causing imprecision in the analysis.
There are six cases in es2022 when such lookup happens.
In all these cases except the fifth case, which is a lookup of "parent", I confirmed the type being more precise.
This commit fixes the issue.