Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
76d464e
baml_language: add throws field to function type representations
rossirpaulo Apr 8, 2026
a0af77c
baml_language: wire throws into function signature construction
rossirpaulo Apr 8, 2026
1f64000
baml_language: finalize typed rethrows for higher-order functions
rossirpaulo Apr 8, 2026
9608710
baml_language: add stored callback enforcement for typed rethrows
rossirpaulo Apr 8, 2026
4282b74
baml_language: add stdlib migration and throws regression coverage
rossirpaulo Apr 8, 2026
84d09cb
Refine typed throws semantics for higher-order functions
rossirpaulo Apr 8, 2026
bab3306
Fix function-type throws validation and optional-call propagation
rossirpaulo Apr 8, 2026
e45b28d
Fix lambda generic scope and optional function-shape matching
rossirpaulo Apr 8, 2026
32fac73
Clean up lambda throws diagnostics and parenthesize optional function…
rossirpaulo Apr 8, 2026
cef2fc8
Update MIR and codegen snapshots for function throws display
rossirpaulo Apr 8, 2026
be22d2d
Update test expectations for typed rethrows changes
rossirpaulo Apr 8, 2026
a5d14b8
Extract callable_boundary module and tighten effect-polymorphic rethrows
rossirpaulo Apr 9, 2026
8845cd3
Complete named callable throws boundary cleanup
rossirpaulo Apr 9, 2026
370e2d1
Merge branch 'canary' into rossirpaulo/typed-rethrows-hof
rossirpaulo Apr 9, 2026
73cdd0f
Refresh function_type_throws MIR and codegen snapshots
rossirpaulo Apr 9, 2026
b640a40
Add UnusedCallbackEffectVar diagnostic for unused callback effect vars
rossirpaulo Apr 9, 2026
aec818c
Align TIR display with actual throws behavior
rossirpaulo Apr 9, 2026
58cbcbe
Add regression tests for generic stored callbacks and heterogeneous c…
rossirpaulo Apr 9, 2026
5333f74
Add generic nominal instantiation soundness and cross-package resolution
rossirpaulo Apr 9, 2026
53b47b8
Propagate named-function throws through typed member field calls
rossirpaulo Apr 9, 2026
1bb6e8b
Render generic args in LSP hover and type display
rossirpaulo Apr 9, 2026
bc521f0
Refresh TIR snapshots for StructuralTy type_args shape change
rossirpaulo Apr 9, 2026
16f2a56
Show declared and inferred throws in LSP function hover
rossirpaulo Apr 9, 2026
0795fdb
Refactor throws propagation and callable resolution
rossirpaulo Apr 9, 2026
7be9e57
Refine package resolution context and throws recovery
rossirpaulo Apr 10, 2026
7327986
Expand throws regression coverage
rossirpaulo Apr 10, 2026
2d58aee
Refine typed throws inference for higher-order callbacks
rossirpaulo Apr 16, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

class TestRegistration {
name string
body () -> null
body () -> null throws unknown
runner TestRunner?
}

class TestSetRegistration {
name string
collector (TestCollector) -> null
collector (TestCollector) -> null throws unknown
runner TestSetRunner?
}

Expand Down
3 changes: 2 additions & 1 deletion baml_language/crates/baml_compiler2_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ pub enum TypeExpr {
value: baml_base::Literal,
attrs: Vec<RawAttribute>,
},
/// Function type: (params) -> return
/// Function type: (params) -> return [throws E]
Function {
params: Vec<FunctionTypeParam>,
ret: Box<TypeExpr>,
throws: Option<Box<TypeExpr>>,
attrs: Vec<RawAttribute>,
},
/// The `unknown` keyword type
Expand Down
10 changes: 9 additions & 1 deletion baml_language/crates/baml_compiler2_ast/src/disambiguate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,19 @@ fn validate_type_expr_tree(expr: &TypeExpr, diagnostics: &mut Vec<(String, text_
validate_type_expr_tree(v, diagnostics);
}
}
TypeExpr::Function { params, ret, .. } => {
TypeExpr::Function {
params,
ret,
throws,
..
} => {
for p in params {
validate_type_expr_tree(&p.ty, diagnostics);
}
validate_type_expr_tree(ret, diagnostics);
if let Some(throws) = throws {
validate_type_expr_tree(throws, diagnostics);
}
}
_ => {}
}
Expand Down
8 changes: 7 additions & 1 deletion baml_language/crates/baml_compiler2_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ mod tests {
value: value.clone(),
attrs: strip_attrs(attrs),
},
TypeExpr::Function { params, ret, attrs } => TypeExpr::Function {
TypeExpr::Function {
params,
ret,
throws,
attrs,
} => TypeExpr::Function {
params: params
.iter()
.map(|p| crate::ast::FunctionTypeParam {
Expand All @@ -187,6 +192,7 @@ mod tests {
})
.collect(),
ret: Box::new(strip_spans(ret)),
throws: throws.as_ref().map(|t| Box::new(strip_spans(t))),
attrs: strip_attrs(attrs),
},
TypeExpr::Media { kind, attrs } => TypeExpr::Media {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,16 @@ fn lower_base_terminal(type_expr: &CstTypeExpr) -> TypeExpr {
.function_return_type()
.map(|t| lower_type_expr_inner(&t, false))
.unwrap_or(TypeExpr::Unknown { attrs: vec![] });
let throws = type_expr.function_throws_type().map(|throws_clause| {
let throws_type = throws_clause
.type_expr()
.expect("THROWS_CLAUSE should have a type");
Box::new(lower_type_expr_inner(&throws_type, false))
});
return TypeExpr::Function {
params,
ret: Box::new(ret),
throws,
attrs: vec![],
};
}
Expand Down
31 changes: 22 additions & 9 deletions baml_language/crates/baml_compiler2_mir/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,28 @@ pub fn convert_tir2_ty(ty: &Tir2Ty, resolved: &ResolvedAliases) -> Ty {
attr: attr.clone(),
},

// Functions — drop param names
Tir2Ty::Function { params, ret, attr } => Ty::Function {
params: params
.iter()
.map(|(_, t)| convert_tir2_ty(t, resolved))
.collect(),
ret: Box::new(convert_tir2_ty(ret, resolved)),
attr: attr.clone(),
},
// Functions — drop param names; map Never throws to None
Tir2Ty::Function {
params,
ret,
throws,
attr,
} => {
let converted_throws = convert_tir2_ty(throws, resolved);
Ty::Function {
params: params
.iter()
.map(|(_, t)| convert_tir2_ty(t, resolved))
.collect(),
ret: Box::new(convert_tir2_ty(ret, resolved)),
throws: if matches!(converted_throws, Ty::Void { .. }) {
None
} else {
Some(Box::new(converted_throws))
},
attr: attr.clone(),
}
}

// Bottom / sentinel types
Tir2Ty::Never { attr } => Ty::Void { attr: attr.clone() },
Expand Down
Loading
Loading