Skip to content

Commit 6124c52

Browse files
authored
Fix bug in streaming mode (#637)
1 parent 574cf70 commit 6124c52

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/pdl/pdl_interpreter.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,11 @@ def process_advanced_block(
334334
if len(block.defs) > 0:
335335
scope, defs_trace = process_defs(state, scope, block.defs, loc)
336336
block = block.model_copy(update={"defs": defs_trace})
337+
init_state = state
337338
state = state.with_yield_result(
338-
state.yield_result and ContributeTarget.RESULT in block.contribute
339+
state.yield_result
340+
and ContributeTarget.RESULT in block.contribute
341+
and block.parser is None
339342
)
340343
state = state.with_yield_background(
341344
state.yield_background and context_in_contribute(block)
@@ -352,6 +355,8 @@ def process_advanced_block(
352355
if block.parser is not None:
353356
parser = block.parser
354357
result = lazy_apply(lambda r: parse_result(parser, r), result)
358+
if init_state.yield_result and ContributeTarget.RESULT:
359+
yield_result(result, block.kind)
355360
if block.spec is not None and not isinstance(block, FunctionBlock):
356361
result = lazy_apply(
357362
lambda r: result_with_type_checking(

0 commit comments

Comments
 (0)