Skip to content

Commit ed547df

Browse files
committed
.
1 parent 9d77d8f commit ed547df

10 files changed

+40
-36
lines changed

continue.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
- Private name assignments now route through private scope/brand resolution, so instance/static private setter brand-checks across multiple class evaluations (factory/eval/realm variants) are passing alongside the private static getter/setter cases.
2222
- Super() in derived class constructors now finds the owning `this` binding without triggering TDZ ReferenceErrors, so the `this-access-restriction` class definition cases are green in strict and sloppy mode.
2323
- Logical assignment short-circuits skip `PutValue` (including private refs/accessors), and RHS NamedEvaluation now applies to ||=/&&=/??= with identifier LHS, so the logical-assignment cluster (read-only/accessor/non-extensible and name inference) is green.
24-
- `using` and `await using` declarations parse correctly and throw TypeError on non-object initializers, so the explicit resource management statement cases now pass.
24+
- Array index assignments now walk prototype accessors/writable descriptors (including inherited setters) before falling back to element storage, so member-expression for-in targets trigger Array.prototype setters and typed array for-in over resizable buffers enumerates the expected indices.
25+
- `using` and `await using` declarations still TypeError on non-object initializers but now allow initializer-less for-in/of heads with per-iteration lexical environments, so the TDZ/fresh-binding for-of cases are green.
2526

2627
## Next Iteration Plan
27-
1. Re-run the Language suite to refresh the current failure set after the this-access/super binding fixes.
28+
1. Re-run the Language suite to refresh the current failure set after the for-in/of using and array setter fixes.
2829
2. Triage the next largest failing cluster from that run (modules/import/defer if they resurface, otherwise whatever is hottest), adding realm logging if the failure isn’t obvious.
2930
3. Iterate through the refreshed list in priority order, landing targeted fixes and re-running the filtered clusters as they’re addressed.

languagetests.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
ModuleCode_topLevelAwait("language/module-code/top-level-await/module-graphs-does-not-hang.js",True)
8686
ModuleCode_topLevelAwait("language/module-code/top-level-await/module-sync-import-async-resolution-ticks.js",True)
8787
ModuleCode_topLevelAwait_syntax
88-
ModuleCode_topLevelAwait_syntax("language/module-code/top-level-await/syntax/await-expr-dyn-import.js",True)
8988
Statements_asyncGenerator
9089
Statements_asyncGenerator("language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js",False)
9190
Statements_asyncGenerator("language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js",True)
@@ -122,18 +121,6 @@
122121
Statements_forAwaitOf("language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-simple-no-strict.js",False)
123122
Statements_forAwaitOf("language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-simple-no-strict.js",False)
124123
Statements_forAwaitOf("language/statements/for-await-of/async-gen-decl-dstr-obj-id-simple-no-strict.js",False)
125-
Statements_forIn
126-
Statements_forIn("language/statements/for-in/head-lhs-let.js",False)
127-
Statements_forIn("language/statements/for-in/resizable-buffer.js",False)
128-
Statements_forIn("language/statements/for-in/resizable-buffer.js",True)
129-
Statements_forOf
130-
Statements_forOf("language/statements/for-of/head-await-using-bound-names-fordecl-tdz.js",False)
131-
Statements_forOf("language/statements/for-of/head-await-using-bound-names-fordecl-tdz.js",True)
132-
Statements_forOf("language/statements/for-of/head-await-using-fresh-binding-per-iteration.js",True)
133-
Statements_forOf("language/statements/for-of/head-using-bound-names-fordecl-tdz.js",False)
134-
Statements_forOf("language/statements/for-of/head-using-bound-names-fordecl-tdz.js",True)
135-
Statements_forOf("language/statements/for-of/head-using-fresh-binding-per-iteration.js",False)
136-
Statements_forOf("language/statements/for-of/head-using-fresh-binding-per-iteration.js",True)
137124
Statements_function
138125
Statements_function("language/statements/function/param-dflt-yield-non-strict.js",False)
139126
Statements_labeled

src/Asynkron.JsEngine/Ast/ClassDefinitionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static partial class TypedAstEvaluator
8181
}
8282

8383
typedFunction.SetInstanceFields(resolvedInstanceFields);
84-
typedFunction.SetIsClassConstructor(superConstructor is not null);
84+
typedFunction.SetIsClassConstructor(definition.Extends is not null);
8585
typedFunction.SetPrivateNameScope(privateNameScope);
8686
if (privateNameScope is not null)
8787
{

src/Asynkron.JsEngine/Ast/TypedAstEvaluator.AsyncGeneratorFactory.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static partial class TypedAstEvaluator
99
{
1010
private sealed class AsyncGeneratorFactory : IJsCallable, IJsObjectLike, IPropertyDefinitionHost,
1111
IExtensibilityControl,
12-
IFunctionNameTarget
12+
IFunctionNameTarget, ICallableMetadata
1313
{
1414
private readonly JsEnvironment _closure;
1515
private readonly FunctionExpression _function;
@@ -115,6 +115,10 @@ public void EnsureHasName(string name, bool overwriteExisting = false)
115115
public bool IsSealed => _properties.IsSealed;
116116
public bool IsFrozen => _properties.IsFrozen;
117117

118+
public bool IsArrowFunction => false;
119+
public bool DisallowConstruct => true;
120+
public RealmState RealmState => _realmState;
121+
118122
public IEnumerable<string> Keys => _properties.Keys;
119123

120124
public void DefineProperty(string name, PropertyDescriptor descriptor)

src/Asynkron.JsEngine/Ast/TypedAstEvaluator.TypedFunction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ public bool TryDefineProperty(string name, PropertyDescriptor descriptor)
639639

640640
object? initialThisValue;
641641
var initialThisInitialized = true;
642-
if (_isDerivedClassConstructor && _superConstructor is not null)
642+
if (_isDerivedClassConstructor)
643643
{
644644
context.MarkThisUninitialized();
645645
initialThisInitialized = false;
@@ -708,7 +708,7 @@ public bool TryDefineProperty(string name, PropertyDescriptor descriptor)
708708

709709
if (_isClassConstructor && boundThis is JsObject thisInstance)
710710
{
711-
if (_isDerivedClassConstructor && _superConstructor is not null)
711+
if (_isDerivedClassConstructor)
712712
{
713713
pendingFieldInitialization = new PendingClassFieldInitialization(this, functionEnvironment);
714714
context.PushClassFieldInitializer(pendingFieldInitialization);

src/Asynkron.JsEngine/Ast/TypedAstEvaluator.TypedGeneratorFactory.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static partial class TypedAstEvaluator
99
{
1010
private sealed class TypedGeneratorFactory : IJsCallable, IJsObjectLike, IPropertyDefinitionHost,
1111
IExtensibilityControl,
12-
IFunctionNameTarget, ICallerInfo
12+
IFunctionNameTarget, ICallerInfo, ICallableMetadata
1313
{
1414
private readonly JsEnvironment _closure;
1515
private readonly FunctionExpression _function;
@@ -117,6 +117,10 @@ public void EnsureHasName(string name, bool overwriteExisting = false)
117117
public bool IsSealed => _properties.IsSealed;
118118
public bool IsFrozen => _properties.IsFrozen;
119119

120+
public bool IsArrowFunction => false;
121+
public bool DisallowConstruct => true;
122+
public RealmState RealmState => _realmState;
123+
120124
public IEnumerable<string> Keys => _properties.Keys;
121125

122126
public void DefineProperty(string name, PropertyDescriptor descriptor)

src/Asynkron.JsEngine/JsEngine.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -964,12 +964,16 @@ private void EnsureModuleEvaluated(ModuleEntry entry)
964964
/// <summary>
965965
/// Registers a value in the global scope.
966966
/// </summary>
967-
private void SetGlobal(string name, object? value, bool isGlobalConstant = false)
967+
private void SetGlobal(string name, object? value, bool isGlobalConstant = false, bool registerBinding = false)
968968
{
969969
var symbol = Symbol.Intern(name);
970-
// Global built-ins are properties of the global object (ES GlobalDeclarationInstantiation),
971-
// so they are registered as var-scoped bindings rather than lexical declarations.
972-
GlobalEnvironment.Define(symbol, value, isGlobalConstant: isGlobalConstant, isLexical: false);
970+
if (registerBinding)
971+
{
972+
// Only register a binding when explicitly requested (e.g., host-added globals).
973+
// Built-ins defined during engine initialization are exposed as global object
974+
// properties so they don't block later lexical declarations (let/const).
975+
GlobalEnvironment.Define(symbol, value, isGlobalConstant: isGlobalConstant, isLexical: false);
976+
}
973977

974978
// Also mirror globals onto the global object so that code using
975979
// `this.foo` or `global.foo` can see host-provided bindings.
@@ -1003,15 +1007,15 @@ private void SetGlobal(string name, object? value, bool isGlobalConstant = false
10031007
/// </summary>
10041008
public void SetGlobalValue(string name, object? value)
10051009
{
1006-
SetGlobal(name, value);
1010+
SetGlobal(name, value, registerBinding: true);
10071011
}
10081012

10091013
/// <summary>
10101014
/// Registers a host function that can be invoked from interpreted code.
10111015
/// </summary>
10121016
public void SetGlobalFunction(string name, Func<IReadOnlyList<object?>, object?> handler)
10131017
{
1014-
GlobalEnvironment.Define(Symbol.Intern(name), new HostFunction(handler) { Realm = GlobalObject });
1018+
SetGlobal(name, new HostFunction(handler) { Realm = GlobalObject }, registerBinding: true);
10151019
}
10161020

10171021
/// <summary>

src/Asynkron.JsEngine/JsEnvironment.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,16 +1001,6 @@ public bool HasVarDeclaration(Symbol name)
10011001
return true;
10021002
}
10031003

1004-
// For global scope, also check the global object for var declarations
1005-
if (IsGlobalFunctionScope)
1006-
{
1007-
var globalObject = GetRootGlobalObject();
1008-
if (globalObject is not null && globalObject.GetOwnPropertyDescriptor(name.Name) is not null)
1009-
{
1010-
return true;
1011-
}
1012-
}
1013-
10141004
return false;
10151005
}
10161006

src/Asynkron.JsEngine/Runtime/JsOps.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,11 @@ public static bool TryGetPropertyValue(object? target, object? propertyKey, out
16261626

16271627
public static bool IsConstructor(object? value)
16281628
{
1629+
if (value is JsProxy proxy)
1630+
{
1631+
return IsConstructor(proxy.Target);
1632+
}
1633+
16291634
if (value is HostFunction host)
16301635
{
16311636
return host is { IsConstructor: true, DisallowConstruct: false };

src/Asynkron.JsEngine/StdLib/StandardLibrary.TypedArray.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,15 @@ private static HostFunction CreateTypedArrayConstructor<T>(
547547
constructor.SetProperty("BYTES_PER_ELEMENT", (double)bytesPerElement);
548548
prototype.SetPrototype(realm.ObjectPrototype);
549549
prototype.SetProperty("constructor", constructor);
550+
var toStringTagKey = $"@@symbol:{TypedAstSymbol.For("Symbol.toStringTag").GetHashCode()}";
551+
prototype.DefineProperty(toStringTagKey,
552+
new PropertyDescriptor
553+
{
554+
Value = constructorName,
555+
Writable = false,
556+
Enumerable = false,
557+
Configurable = true
558+
});
550559
constructor.DefineProperty("name",
551560
new PropertyDescriptor
552561
{

0 commit comments

Comments
 (0)