Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Jint/Runtime/Interpreter/Expressions/JintYieldExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ namespace Jint.Runtime.Interpreter.Expressions;

internal sealed class JintYieldExpression : JintExpression
{
private readonly JintExpression? _argument;

public JintYieldExpression(YieldExpression expression) : base(expression)
{
_argument = expression.Argument is not null ? Build(expression.Argument) : null;
}

protected override object EvaluateInternal(EvaluationContext context)
Expand Down Expand Up @@ -171,9 +174,9 @@ protected override object EvaluateInternal(EvaluationContext context)

// Normal yield: evaluate argument and yield the value
JsValue value;
if (expression.Argument is not null)
if (_argument is not null)
{
value = Build(expression.Argument).GetValue(context);
value = _argument.GetValue(context);

// If the argument evaluation suspended the generator (nested yield), propagate
// the suspension up without yielding again - the inner yield already suspended
Expand Down
Loading