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

Fixes #5477 - Forces computed property names within classes to be executed in strict mode #5689

Merged
merged 1 commit into from
Sep 15, 2018

Conversation

wyrichte
Copy link
Collaborator

Forces computed property names within classes to be executed in strict mode.
The ECMA spec requires that a class definition is always strict mode code, this includes computed property names within classes. A flag, forceStrictModeForClassComputedPropertyName, is added into ByteCodeGenerator.h. When set, this flag will force bytecode opcodes to be emitted in strict mode when avaliable. This flag is set outside of emit calls under the condition that the bytecode being emitted corresponds to computed property names within classes.

@wyrichte wyrichte changed the title Fixes #5477 Fixes #5477 - Forces computed property names within classes to be executed in strict mode Sep 11, 2018

// Strict mode must be enforced on the evaluation of computed property names inside
// classes, thus enable the flag if the computed property name is a class member.
byteCodeGenerator->forceStrictModeForClassComputedPropertyName = isClassMember;
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like maybe here we should be setting isClassMember || prevFlag. Consider the following (which might be a nice test case too): class C { [{[a.b=3]: 4}[3]]() {} }. Inside the computed method name on the class (strict mode), we have a computed property name for an object literal (which I believe should also be strict mode, because strict mode affects anything lexically inside the expression).

Copy link
Contributor

@sethbrenith sethbrenith left a comment

Choose a reason for hiding this comment

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

:shipit:

…s to be executed in strict mode

The ECMA spec requires that a class definition is always strict mode code, this includes computed property names within classes. A flag, forceStrictModeForClassComputedPropertyName, is added into ByteCodeGenerator.h. When set, this flag will force bytecode opcodes to be emitted in strict mode when avaliable. This flag is set outside of emit calls under the condition that the bytecode being emitted corresponds to computed property names within classes.
pleath pushed a commit to pleath/ChakraCore that referenced this pull request Sep 14, 2018
…mputed property names within classes to be executed in strict mode

Merge pull request chakra-core#5689 from wyrichte:bug_5477_fixed

Forces computed property names within classes to be executed in strict mode.
The ECMA spec requires that a class definition is always strict mode code, this includes computed property names within classes. A flag, forceStrictModeForClassComputedPropertyName, is added into ByteCodeGenerator.h. When set, this flag will force bytecode opcodes to be emitted in strict mode when avaliable. This flag is set outside of emit calls under the condition that the bytecode being emitted corresponds to computed property names within classes.
@chakrabot chakrabot merged commit 4f3f3bf into chakra-core:master Sep 15, 2018
@wyrichte wyrichte self-assigned this Sep 26, 2018
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.

6 participants