Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/pdl/pdl_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions tests/test_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class 'int'>"
)


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}