Skip to content

Commit e750473

Browse files
committed
.
1 parent c15d3f7 commit e750473

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Asynkron.JsEngine/Ast/LoopPlanExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ private JsEnvironment CreatePerIterationEnvironment(JsEnvironment currentIterati
126126
// Get the current value from the current iteration environment
127127
var identifierExpr = new IdentifierExpression(null, bindingName);
128128
var currentValue = EvaluateExpression(identifierExpr, currentIterationEnvironment, context);
129+
var isConstBinding = currentIterationEnvironment.IsConstBinding(bindingName);
129130

130131
// Define the binding in the new iteration environment
131132
// Use let semantics (isLexical=true, isConst=false by default, but the original
132133
// declaration kind doesn't matter for the copy)
133134
newIterationEnvironment.Define(
134135
bindingName,
135136
currentValue,
136-
isConst: false,
137+
isConst: isConstBinding,
137138
isGlobalConstant: false,
138139
isLexical: true,
139140
blocksFunctionScopeOverride: false,

src/Asynkron.JsEngine/Parser/TypedAstParser.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,9 +1114,9 @@ private FunctionExpression ParseClassMethod(Symbol? functionName, Token methodNa
11141114
bool isAsync)
11151115
{
11161116
Consume(TokenType.LeftParen, "Expected '(' after method name.");
1117+
using var _ = EnterFunctionContext(isAsync, isGenerator);
11171118
var parameters = ParseParameterList();
11181119
Consume(TokenType.RightParen, "Expected ')' after method parameters.");
1119-
using var _ = EnterFunctionContext(isAsync, isGenerator);
11201120
var body = ParseBlock();
11211121
var source = body.Source ?? CreateSourceReference(methodNameToken);
11221122
return new FunctionExpression(source, functionName, parameters, body, isAsync, isGenerator,
@@ -2865,9 +2865,9 @@ private ExpressionNode ParseObjectLiteral()
28652865
if (Check(TokenType.LeftParen))
28662866
{
28672867
Advance(); // (
2868+
using var _ = EnterFunctionContext(true, isAsyncGeneratorMethod);
28682869
var parameters = ParseParameterList();
28692870
Consume(TokenType.RightParen, "Expected ')' after method parameters.");
2870-
using var _ = EnterFunctionContext(true, isAsyncGeneratorMethod);
28712871
var body = ParseBlock();
28722872
var asyncMethod = new FunctionExpression(body.Source ?? asyncKeySource, null, parameters,
28732873
body,
@@ -2920,9 +2920,9 @@ private ExpressionNode ParseObjectLiteral()
29202920

29212921
if (Match(TokenType.LeftParen))
29222922
{
2923+
using var _ = EnterFunctionContext(false, isGeneratorMethod);
29232924
var parameters = ParseParameterList();
29242925
Consume(TokenType.RightParen, "Expected ')' after method parameters.");
2925-
using var _ = EnterFunctionContext(false, isGeneratorMethod);
29262926
var body = ParseBlock();
29272927
method = new FunctionExpression(body.Source, null, parameters, body, false, isGeneratorMethod);
29282928
kind = ObjectMemberKind.Method;
@@ -3199,6 +3199,7 @@ private ExpressionNode ParseFunctionExpression(Symbol? explicitName = null, bool
31993199

32003200
private FunctionExpression ParseFunctionTail(Symbol? name, Token startToken, bool isAsync, bool isGenerator)
32013201
{
3202+
using var _ = EnterFunctionContext(isAsync, isGenerator);
32023203
Consume(TokenType.LeftParen, "Expected '(' after function name.");
32033204
var parameters = ParseParameterList();
32043205
Consume(TokenType.RightParen, "Expected ')' after parameters.");
@@ -3224,7 +3225,6 @@ private FunctionExpression ParseFunctionTail(Symbol? name, Token startToken, boo
32243225
ValidateStrictModeParameters(parameters);
32253226
}
32263227

3227-
using var _ = EnterFunctionContext(isAsync, isGenerator);
32283228
var body = ParseBlock(leftBraceConsumed: true);
32293229
var source = body.Source ?? CreateSourceReference(startToken);
32303230
return new FunctionExpression(source, name, parameters, body, isAsync, isGenerator, WasAsync: isAsync);

0 commit comments

Comments
 (0)