Skip to content
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 class declaration hoisting and typeof double-evaluation #1104

Merged
merged 1 commit into from
Mar 8, 2022

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Mar 8, 2022

  • fix class declaration hoisting (to actually make it hoist)
  • fix typeof evaluating value (getter) when only reference should be retrieved, has perf benefit too
  • marking now failing module tests as skipped, need to be addressed in Module support fixes and improvements #1102

/cc @christianrondeau

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsConstantDeclaration(this Declaration d)
{
return d is VariableDeclaration { Kind: VariableDeclarationKind.Const };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It hurts somewhere, but I can't locate it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's equivalent to return d is VariableDeclaration v && v.Kind == VariableDeclarationKind.Const; right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, takes some time to digest, but it's quite nice syntax, like is/are both these true - type and it's property values

@lahma
Copy link
Collaborator Author

lahma commented Mar 8, 2022

I'm going to merge this with green build as there's test coverage and this is not much of rocket science...

@lahma lahma merged commit 298ff59 into sebastienros:main Mar 8, 2022
@lahma lahma deleted the hoisting-fixes branch March 8, 2022 15:47
@sebastienros
Copy link
Owner

So a class can't be used until declared? That's the opposite of hoisting, right?

@lahma
Copy link
Collaborator Author

lahma commented Mar 8, 2022

well class needs to be registered during script initialization, like anything in lexical scope, then later on it will be initialized to correct value and access before initialization (JintClassDeclaration runs) should cause reference error. Now earlier it was considered undefined as it hadn't even been registered until the JintClassDeclaration runtime.

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.

2 participants