diff --git a/src/pdl/pdl_interpreter.py b/src/pdl/pdl_interpreter.py index d5b0f76e5..8d673570c 100644 --- a/src/pdl/pdl_interpreter.py +++ b/src/pdl/pdl_interpreter.py @@ -453,6 +453,12 @@ def process_advanced_block( if block.trace_error_on_retry: scope = set_error_to_scope_for_retry(scope, error, block.pdl__id) continue + state = init_state.with_yield_result( + init_state.yield_result and ContributeTarget.RESULT in block.contribute + ) + state = state.with_yield_background( + state.yield_background and context_in_contribute(block) + ) ( result, background, diff --git a/tests/test_fallback.py b/tests/test_fallback.py index bc33cfbef..6bd3934b1 100644 --- a/tests/test_fallback.py +++ b/tests/test_fallback.py @@ -76,3 +76,15 @@ def test_type_checking_in_fallback(): str(exc.value.message) == "Type errors during spec checking:\nline 4 - Error should be of type " ) + + +def test_fallback_and_parser(): + prog_str = """ +model: "raise an error" +parser: json +spec: { xxx: string, age: integer} +fallback: + data: { "xxx": "rosa", "age": 3 } +""" + result = exec_str(prog_str) + assert result == {"xxx": "rosa", "age": 3}