Skip to content

Commit fc3b3a4

Browse files
committed
first pass
1 parent 4833fbe commit fc3b3a4

40 files changed

Lines changed: 2946 additions & 613 deletions

File tree

baml_language/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baml_language/crates/baml_builtins2/baml_std/baml/ns_host/host.baml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
/// throw rides the VM's normal exception unwinder. A host value left
1111
/// untyped at the boundary erases `E` to `unknown`, which accepts any
1212
/// thrown value — including an opaque `baml.errors.HostCallable`.
13+
///
14+
/// `args` is a two-element pack the VM builds in `host_closure_call_sysop`:
15+
/// `[positional_required_args, { optional_name: value }]`. The VM has already
16+
/// split the call by the callable's declared params (using the captured
17+
/// `Object::HostClosure`), dropping omitted optionals — so each bridge applies
18+
/// its own calling convention (TS `$opts`, Python kwargs) without needing the
19+
/// callee type on the wire.
1320
function call_host_value<T, E>(handle: HostValue, args: unknown[])
1421
-> T throws E {
1522
$rust_io_function

baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_builtin_package_listing.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ function future.any <builtin>/baml/ns_future/futur
105105
class glob.ScanOptions <builtin>/baml/ns_glob/glob.baml:2
106106
class glob.Glob <builtin>/baml/ns_glob/glob.baml:18
107107
function glob.new <builtin>/baml/ns_glob/glob.baml:34
108-
function host.call_host_value <builtin>/baml/ns_host/host.baml:13
109-
class host.HostValue <builtin>/baml/ns_host/host.baml:20
108+
function host.call_host_value <builtin>/baml/ns_host/host.baml:20
109+
class host.HostValue <builtin>/baml/ns_host/host.baml:27
110110
class http.Request <builtin>/baml/ns_http/http.baml:8
111111
class http.Response <builtin>/baml/ns_http/http.baml:16
112112
class http.SseStream <builtin>/baml/ns_http/http.baml:94
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// A host-callable parameter whose callable type tries to give one of its own
2+
// arguments a default (`y: int = 10`). A default is a property of a function
3+
// *declaration*, not a function *type*, so the parser rejects it — the same
4+
// `E0010` rule that rejects `type T = (a: int = 1) -> int`, here exercised in
5+
// the host-callback parameter position. This pins that an optional callback
6+
// argument must be written with the `?` marker (`y?: int`), never a default.
7+
function call_with_defaulted_callback(callback: (x: int, y: int = 10) -> string, x: int) -> string {
8+
callback(x)
9+
}

baml_language/crates/baml_tests/snapshots/broken_syntax/optional_parameter_defaults/baml_tests__broken_syntax__optional_parameter_defaults__01_lexer__callback_param_defaults.snap

Lines changed: 157 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baml_language/crates/baml_tests/snapshots/broken_syntax/optional_parameter_defaults/baml_tests__broken_syntax__optional_parameter_defaults__02_parser__callback_param_defaults.snap

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baml_language/crates/baml_tests/snapshots/broken_syntax/optional_parameter_defaults/baml_tests__broken_syntax__optional_parameter_defaults__05_diagnostics.snap

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baml_language/crates/baml_tests/src/compiler2_tir/snapshots/baml_tests__compiler2_tir__phase5__snapshot_baml_package_items.snap

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baml_language/crates/bex_engine/src/conversion.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,10 @@ impl BexEngine {
585585
ret_ty: Box::new(ret),
586586
throws_ty: Box::new(normalized_throws),
587587
arity: params.len(),
588+
// Capture the declared params (names + optionality) so the VM
589+
// can split the call args into positional + supplied-optional
590+
// (by name) on dispatch, for the per-bridge argument reshape.
591+
params: Box::new(params.clone()),
588592
};
589593
Value::object(
590594
holder

0 commit comments

Comments
 (0)