es-meta / esmeta

ECMAScript Specification (ECMA-262) Metalanguage
BSD 3-Clause "New" or "Revised" License
175 stars 12 forks source link

Add ContainsCondition #202

Closed d01c2 closed 5 months ago

d01c2 commented 5 months ago

This PR includes adding ContainsCondition for metalanguage. It supports three different targets:

1. Simple Expression Target

_F_ contains *"i"*
_declaredFunctionNames_ does not contain _fn_

2. Additional Constraints for Fields with whose

_module_.[[LoadedModules]] contains a Record whose [[Specifier]] is _required_
_referrer_.[[LoadedModules]] contains a Record whose [[Specifier]] is _specifier_

3. Additional Constraints with such that

_O_.[[PrivateElements]] contains a PrivateElement _pe_ such that _pe_.[[Key]] is _P_
_container_ contains a PrivateElement _pe_ such that _pe_.[[Key]] is _element_.[[Key]]
d01c2 commented 5 months ago

It seems like there has been a change in the specification from ES2022. The original phrase in same file,

If _container_ contains a PrivateElement whose [[Key]] is _element_.[[Key]], then 1. Let _existing_ be that PrivateElement,

has been revised in the latest version to

If _container_ contains a PrivateElement _pe_ such that _pe_.[[Key]] is _element_.[[Key]], then

This change might introduce challenges when writing compiler code due to the mixing of conditions and code within the scope.

By commits above, ClassTail[0,2].ClassDefinitionEvaluation.ir have missing IR code which defines _pe_. In this reason, test262-test throws [InterpreterError] unknown variable: pe. Maybe we have to rewrite EContains from scratch unless we rewrite IR manually.

jhnaldo commented 5 months ago

I changed the title of this PR and updated the explanation according to the latest revision.

jhnaldo commented 5 months ago

This summarizes the test262-test result on my M2 Max MacBook Pro.

- time: 1,028,192 ms [17:08]
- total: 49,741
  - not-supported (N): 25,100
  - pass (P): 24,641
- pass-rate: P/P = 24,641/24,641 (100.00%)