feat: support boolean conditional expressions

This commit is contained in:
2026-10-29 21:47:45 +01:00
parent b832504f10
commit 46fc7f4c46
7 changed files with 161 additions and 10 deletions
+12
View File
@@ -4349,6 +4349,18 @@ expression_type proc(state @mut State, id ast.NodeId, depth usize) ast.NodeId !
.literal_bool: return try builtin(state, id, .bool)
.literal_string: return try builtin(state, id, .string)
.literal_void: return try builtin(state, id, .void)
.match_expr: {
result := no_node
for (0..ast.match_arm_count(&state.tree, id)) |i| {
arm :: ast.match_arm_view(&state.tree, ast.match_arm(&state.tree, id, i))
if (!arm.expression) return no_node
annotation :: try expression_type(state, arm.body, depth + 1)
if (annotation == no_node) continue
result = annotation
if (!flexible(state, arm.body)) return result
}
return result
}
.builtin_call: {
name :: ast.literal_text(&state.tree, ast.builtin_call(&state.tree, id).name)
count :: ast.call_arg_count(&state.tree, id)