Skip to content

Commit f2c880b

Browse files
committed
fix incorrect none detection
1 parent a6fbcf1 commit f2c880b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

grape/automaton_generator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ def transition(p: Program, args: tuple[str, ...]) -> str | None:
8383
else:
8484
return str(p)
8585

86+
whatever = target_type.lower() == "none"
87+
8688
return Constraint(
8789
str,
8890
transition,
89-
lambda s: target_type == "none"
91+
lambda s: whatever
9092
or (
9193
types.return_type(dsl.primitives[s][0]) == target_type
9294
if s in dsl.primitives
@@ -98,8 +100,11 @@ def transition(p: Program, args: tuple[str, ...]) -> str | None:
98100
def grammar_by_saturation(
99101
dsl: DSL, requested_type: str, constraints: list[Constraint] = []
100102
) -> DFTA[Any, Program]:
103+
"""
104+
Returns a specialized grammar with the given constraints.
105+
"""
101106
args, rtype = types.parse(requested_type)
102-
whatever = rtype == "None"
107+
whatever = rtype.lower() == "none"
103108
rules: dict[tuple[Program, tuple[str, ...]], str] = {}
104109

105110
added = True

0 commit comments

Comments
 (0)