Skip to content

Commit aae9855

Browse files
committed
Fix carg generation bug
1 parent d12afa7 commit aae9855

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • src/styx/backend/generic/gen

src/styx/backend/generic/gen/app.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def _compile_build_cargs(
101101
cargs_exprs: list[MStr] = [] # string expressions for building cargs
102102
cargs_exprs_maybe_null: list[MStr] = [] # string expressions for building cargs if parameters may be null
103103

104+
always_emit = False
105+
104106
for carg in group.cargs:
105107
carg_exprs: list[MStr] = [] # string expressions for building a single carg
106108
carg_exprs_maybe_null: list[MStr] = []
@@ -131,6 +133,7 @@ def _compile_build_cargs(
131133
)
132134
)
133135
else:
136+
always_emit = True
134137
carg_exprs_maybe_null.append(param_as_mstr)
135138

136139
# collapse and add single carg to cargs expressions
@@ -144,13 +147,13 @@ def _compile_build_cargs(
144147
# Append to cargs buffer
145148
buf_appending: LineBuffer = []
146149
if len(cargs_exprs) == 1:
147-
for str_symbol in cargs_exprs_maybe_null if len(group_conditions_py) > 1 else cargs_exprs:
150+
for str_symbol in cargs_exprs_maybe_null if (len(group_conditions_py) > 1 and not always_emit) else cargs_exprs:
148151
buf_appending.extend(lang.mstr_cargs_add("cargs", str_symbol))
149152
else:
150-
x = cargs_exprs_maybe_null if len(group_conditions_py) > 1 else cargs_exprs
153+
x = cargs_exprs_maybe_null if (len(group_conditions_py) > 1 and not always_emit) else cargs_exprs
151154
buf_appending.extend(lang.mstr_cargs_add("cargs", x))
152155

153-
if len(group_conditions_py) > 0:
156+
if len(group_conditions_py) > 0 and not always_emit:
154157
func.body.extend(
155158
lang.if_else_block(
156159
condition=lang.expr_conditions_join_or(group_conditions_py),

0 commit comments

Comments
 (0)