-
Notifications
You must be signed in to change notification settings - Fork 104
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
Fix incorrect function.name
for aliased imports
#1484
base: master
Are you sure you want to change the base?
Conversation
* Replace typecase with `satisfies` operator * Update return type
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 just have some doubts on the code quality as follows:
@@ -268,6 +268,7 @@ function prepareBuiltins(oldBuiltins: Map<string, any>) { | |||
} | |||
} | |||
newBuiltins.set('undefined', undefined) | |||
newBuiltins.set('Object', Object) |
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.
Not sure if this is the right move; what are the implications of this? Perhaps someone could verify/advise.
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 see that you are updating the name property in the function object. But here, are you trying to add the name "Object" to the names of builtins that are visible from Source programs?
const importedNames = ( | ||
importsToAdd.filter(node => node.type === 'VariableDeclaration') as es.VariableDeclaration[] | ||
).flatMap(node => |
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'm not sure if there's a less hacky way to handle this...
`satisfies` is unfortunately only introduced in TS 4.9.
Pull Request Test Coverage Report for Build 7593472306
💛 - Coveralls |
If multiple files alias the same import the name information is lost // a.js
import { show as s } from 'rune';
export function a(x) {
return s(x);
}
// b.js
import { show as b } from 'rune';
import { a } from './a.js';
b(0);
a(0); would theoretically cause the second call to |
Uses
Object.defineProperty
to set the correctfunction.name
value for aliased imports in:Did not do so for
interpreter/interpreter.ts
due to the deprecation note in #1476.How to test
Consider the following program:
Previously, this will result in the following error:
Now, it will result in:
Tested with: