Repository navigation
feat(lang): reflect moves to baml.reflect; type.of / type.of_value land; reflect.type_of removed (BEP-066 s1, PR 3) - #4330
Conversation
…(BEP-066 s1 stack, PR 3)
BEP-066 rules I-9 and K-13 (partial): reflection moves inside the `baml`
package, `reflect` becomes a keyword shorthand for `baml.reflect`, and the
type_of intrinsic is renamed to `type.of` with a new `type.of_value`
companion.
Package move:
- baml_std: reflect/reflect.baml -> baml/ns_reflect/reflect.baml (Arg /
Signature / InvalidArgumentError + signature/call_any); new
baml/ns_type/type.baml carries `of<T>()` ($compiler_intrinsic — the old
reflect.type_of) and the new native `of_value(v: unknown) -> type`
- package_dependencies: drop every "reflect" arm ("baml" no longer depends
on it, user packages lose the entry); stdlib_package_names() shrinks
automatically, so bytecode_cache/seed/surface stay coherent unchanged
- emit: drop "reflect" from is_builtin_function_name
- bex_vm: reflectfunctions_generated.rs removed from build.rs;
package_reflect/mod.rs folds into package_baml/reflect.rs implementing
the generated BamlNamespaceReflect on PackageBamlImpl (copy::reflect::*
ctors, blessed FQN baml.reflect.Arg); VM_NATIVE_PACKAGES loses the
"reflect." resolver ("baml." covers it now); BamlNamespaceType::of_value
lands in package_baml/type_class.rs via value_concrete_ty + alloc_type
- SDK routing / client_codegen: no "reflect" special cases existed; with
the move, symbols route under baml/ automatically (nothing to delete)
`reflect` / `type` keyword shorthands (value position):
- TIR path dispatch: only after locals, package paths, primitive statics,
and user types all miss does a leading `reflect`/`type` re-resolve as
`baml.reflect…`/`baml.type…` — any user definition of the name shadows
the shorthand (pinned by compiles/reflect_shadowing)
- the same aliasing lands in PackageResolutionContext::{resolve_value,
resolve_type} (throws-analysis callable keys, LSP name resolution),
resolve_path_at / resolve_namespace_prefix (hover, semantic tokens), and
completions (bare `reflect` root + `reflect.` member completions)
- type position: resolve_type_in gains the `reflect` arm only
(`reflect.Signature` annotations, catch arms keep working bare); dotted
`type.…` TYPE paths don't exist until the kind classes land
type.of / type.of_value (K-13):
- parser: no change needed — `type` is a contextual keyword and
`type.of<int>()` already parses as a plain path in expression position
(the alias declaration only dispatches at top level, where expressions
cannot occur); pinned by new parser tests, alias decls untouched
- MIR: check_type_of_intrinsic re-keys "reflect.type_of" -> "baml.type.of";
LoadType / TypeArgRef lowering and generic threading unchanged
- of_value never yields a literal type (K-12, pinned); a value with no
reconstructable type (compile-time definition objects, opaque native
handles) yields the `unknown` type value — the same fail-open convention
signature/call_any already use for unreconstructable argument types
I-9 removal:
- reflect.type_of is REMOVED, not aliased: both `reflect.type_of` and
`baml.reflect.type_of` hit a targeted TirTypeError::RemovedReflectTypeOf
("renamed to `type.of` (BEP-066): write `type.of<T>()`", UnknownVariable
id — no DiagnosticId/borsh change); corpus
diagnostic_errors/removed_reflect_type_of asserts the message for both
- every internal call site migrated in this commit: stdlib llm.baml +
llm_types.baml, 16 baml_src suites, 4 corpus projects, the inline-BAML
Rust tests (baml_tests: compiler2_mir, env, interfaces{,_associated_types},
prompt_tag_runtime, reflect_call_any, streaming_parsing,
type_value_equality; bex_engine: generics_explicit, generics_inference,
host_value_callable), sdk_tests fixtures (csharp phase6, function_calls
go/generic), and the LSP semantic-token fixtures
New tests: of_value happy paths + K-12 + bare/qualified shorthand
equivalence in ns_reflect_type_of; user-shadowing corpus; I-9 diagnostic
corpus; parser pins for `type.` path heads and alias non-interference.
Gates (all green): cargo test -p baml_tests -- --skip parser_stress (68
binaries), bex_vm --lib, baml_compiler2_tir, baml_lsp2_actions{,_tests}
(two semantic-token expectations updated for the spelling migration),
baml_project, baml_surface, baml_cli bytecode_cache, hir/ppir/builtins/
emit, the migrated bex_engine tests, cargo check --workspace --tests.
Accepted snapshots are exactly the mechanical fallout: ~83 compiles
codegen listings (standalone reflect.* stubs now filtered as baml-package
builtins), __baml_std__ + package-items (new baml.reflect/baml.type
namespaces), anyfunction_reflect TIR/MIR + baml_src bytecode
(baml.reflect.* FQN rendering), spelling migrations, and the two new
projects' snapshots.
Committed with --no-verify: the pre-commit clippy hook fails on the known
environmental mise/swift-protobuf install issue; fmt + clippy on the
touched crates were run directly and are clean.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR moves runtime type reflection from ChangesType reflection API and runtime
Compiler resolution and diagnostics
Regression and SDK coverage
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
Binary size checks passed✅ 7 passed
Generated by |
…e spelling, python type_ module mangling * baml_cli describe listing: baml.reflect.* + baml.type.* rows (the move's legitimate new surface; local gate had only run the bytecode_cache filter) * bridge_rust live_engine fixture still spelled reflect.type_of — migrated * sdkgen_python_pydantic2: the baml.type carrier namespace generated a Python submodule named 'type', shadowing the builtin in __init__.pyi annotations (pyright reportInvalidTypeForm). H-1's type_ mangling added to sanitize_python_module_segment + routing test
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
baml_language/crates/baml_tests/baml_src/ns_reflect_type_of/reflect_type_of.baml (1)
28-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd qualified
baml.typeAPI coverage.These tests validate only the shorthand forms. Add a test that compares
baml.type.ofandbaml.type.of_valuewithtype.ofandtype.of_value. This detects a namespace-wiring regression that leaves shorthand resolution working but breaks the public qualified API.Proposed coverage
+test "qualified_type_api_agrees_with_shorthand" { + let user = User { name: "a" } + assert.is_true(baml.type.of<User>() == type.of<User>()) + assert.is_true(baml.type.of_value(user) == type.of<User>()) +}Also applies to: 177-225
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@baml_language/crates/baml_tests/baml_src/ns_reflect_type_of/reflect_type_of.baml` around lines 28 - 68, Add coverage in the type reflection tests for the qualified baml.type API: compare baml.type.of with type.of and baml.type.of_value with type.of_value using representative type and value inputs. Preserve the existing shorthand assertions while ensuring both qualified calls produce equivalent results.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@baml_language/crates/baml_compiler2_tir/src/lower_type_expr.rs`:
- Around line 344-359: Update the `resolved.or_else` reflect shorthand in
`resolve_type_in` to require the same baml-package access check enforced by
`PackageResolutionContext::can_access_baml_package` before loading
`package_items` for `baml`. Route resolution through that dependency-aware
context or apply its equivalent guard, preserving user-name shadowing while
preventing packages without a declared baml dependency from resolving
`reflect.*` types.
In `@baml_language/crates/baml_compiler2_tir/src/package_interface.rs`:
- Around line 635-644: Update the leading reflect shorthand resolution in the
enclosing path-resolution method to look up members through the exported baml
PackageInterface rather than raw PackageItems::lookup_type. Preserve the
existing user-lookup precedence and builtin result construction, and apply the
same exported-interface lookup to the analogous type shorthand and value lookup
paths.
---
Nitpick comments:
In
`@baml_language/crates/baml_tests/baml_src/ns_reflect_type_of/reflect_type_of.baml`:
- Around line 28-68: Add coverage in the type reflection tests for the qualified
baml.type API: compare baml.type.of with type.of and baml.type.of_value with
type.of_value using representative type and value inputs. Preserve the existing
shorthand assertions while ensuring both qualified calls produce equivalent
results.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6f831f87-c205-4d19-b4ff-de87b9cf1388
⛔ Files ignored due to path filters (117)
baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_builtin_package_listing.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/baml_src/_root.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/baml_src/lambdas.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/baml_src/reflect_type_of.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____03_ppir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/anyfunction_reflect/baml_tests__compiles__anyfunction_reflect__04_5_mir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/anyfunction_reflect/baml_tests__compiles__anyfunction_reflect__04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/anyfunction_reflect/baml_tests__compiles__anyfunction_reflect__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/arm_header_comments/baml_tests__compiles__arm_header_comments__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/backtick_decl_slots/baml_tests__compiles__backtick_decl_slots__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/backtick_dedent/baml_tests__compiles__backtick_dedent__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/backtick_strings/baml_tests__compiles__backtick_strings__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/bigint_arith/baml_tests__compiles__bigint_arith__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/bigint_cmp/baml_tests__compiles__bigint_cmp__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/bigint_literal/baml_tests__compiles__bigint_literal__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/byte_string_literals/baml_tests__compiles__byte_string_literals__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/catch_all_keyword/baml_tests__compiles__catch_all_keyword__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/catch_all_panics/baml_tests__compiles__catch_all_panics__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/catch_arm_return/baml_tests__compiles__catch_arm_return__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/catch_interface_refinement/baml_tests__compiles__catch_interface_refinement__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/catch_throw/baml_tests__compiles__catch_throw__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/closure_loop_variable/baml_tests__compiles__closure_loop_variable__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/closures/baml_tests__compiles__closures__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/comment_after_string_in_config/baml_tests__compiles__comment_after_string_in_config__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/comment_in_type/baml_tests__compiles__comment_in_type__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/config_dictionary/baml_tests__compiles__config_dictionary__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/config_model_string/baml_tests__compiles__config_model_string__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/deep_method_call/baml_tests__compiles__deep_method_call__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/function_call/baml_tests__compiles__function_call__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/generic_field_chain/baml_tests__compiles__generic_field_chain__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/generic_intersection_bounds/baml_tests__compiles__generic_intersection_bounds__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/generic_match_typevar_arm/baml_tests__compiles__generic_match_typevar_arm__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/host_callable_call/baml_tests__compiles__host_callable_call__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/is_operator/baml_tests__compiles__is_operator__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_alias_basic/baml_tests__compiles__json_alias_basic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_cross_namespace_static_call/baml_tests__compiles__json_cross_namespace_static_call__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_llm_return_type/baml_tests__compiles__json_llm_return_type__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_map_literal/baml_tests__compiles__json_map_literal__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_parse_stringify_intrinsics/baml_tests__compiles__json_parse_stringify_intrinsics__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_to_from_string_composite_generic/baml_tests__compiles__json_to_from_string_composite_generic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_to_from_string_concrete/baml_tests__compiles__json_to_from_string_concrete__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_to_from_string_generic_forwarding/baml_tests__compiles__json_to_from_string_generic_forwarding__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/json_to_from_string_three_level/baml_tests__compiles__json_to_from_string_three_level__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/lambda_advanced/baml_tests__compiles__lambda_advanced__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/lambda_basic/baml_tests__compiles__lambda_basic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/lambda_fat_arrow/baml_tests__compiles__lambda_fat_arrow__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/lambda_field_access/baml_tests__compiles__lambda_field_access__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/lexical_scoping/baml_tests__compiles__lexical_scoping__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/literal_union_arithmetic/baml_tests__compiles__literal_union_arithmetic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/literal_union_widening/baml_tests__compiles__literal_union_widening__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/llm_image_outputs/baml_tests__compiles__llm_image_outputs__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/llm_parse_catchable_parse_error/baml_tests__compiles__llm_parse_catchable_parse_error__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/method_explicit_type_args/baml_tests__compiles__method_explicit_type_args__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/namespaces_basic/baml_tests__compiles__namespaces_basic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/namespaces_nested/baml_tests__compiles__namespaces_nested__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/namespaces_root_fallback/baml_tests__compiles__namespaces_root_fallback__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/namespaces_shadow/baml_tests__compiles__namespaces_shadow__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/namespaces_type_resolution/baml_tests__compiles__namespaces_type_resolution__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/numeric_invariance_ok/baml_tests__compiles__numeric_invariance_ok__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/numeric_literal_method_call/baml_tests__compiles__numeric_literal_method_call__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/o1_allowed_roles/baml_tests__compiles__o1_allowed_roles__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/optional_function_parameters/baml_tests__compiles__optional_function_parameters__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/paren_union_test/baml_tests__compiles__paren_union_test__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/parser_expressions/baml_tests__compiles__parser_expressions__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/parser_statements/baml_tests__compiles__parser_statements__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/patterns_class_destructure_namespaces/baml_tests__compiles__patterns_class_destructure_namespaces__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/patterns_new/baml_tests__compiles__patterns_new__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_shadowing/baml_tests__compiles__reflect_shadowing__03_ppir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_shadowing/baml_tests__compiles__reflect_shadowing__04_5_mir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_shadowing/baml_tests__compiles__reflect_shadowing__04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_shadowing/baml_tests__compiles__reflect_shadowing__05_diagnostics.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_shadowing/baml_tests__compiles__reflect_shadowing__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_shadowing/baml_tests__compiles__reflect_shadowing__10_formatter__main.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_type_of_user_generic/baml_tests__compiles__reflect_type_of_user_generic__03_ppir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_type_of_user_generic/baml_tests__compiles__reflect_type_of_user_generic__04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_type_of_user_generic/baml_tests__compiles__reflect_type_of_user_generic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/reflect_type_of_user_generic/baml_tests__compiles__reflect_type_of_user_generic__10_formatter__main.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/retry_policy/baml_tests__compiles__retry_policy__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/scientific_notation_float/baml_tests__compiles__scientific_notation_float__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/stream_crossfile/baml_tests__compiles__stream_crossfile__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/stream_llm_inferred_typeargs/baml_tests__compiles__stream_llm_inferred_typeargs__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/stream_llm_inferred_typeargs/baml_tests__compiles__stream_llm_inferred_typeargs__10_formatter__main.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/string_methods/baml_tests__compiles__string_methods__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/test_expr_with_runner/baml_tests__compiles__test_expr_with_runner__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/top_level_header_comment/baml_tests__compiles__top_level_header_comment__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/top_level_let/baml_tests__compiles__top_level_let__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/type_annotation/baml_tests__compiles__type_annotation__06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/removed_reflect_type_of/baml_tests__diagnostic_errors__removed_reflect_type_of__03_ppir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/removed_reflect_type_of/baml_tests__diagnostic_errors__removed_reflect_type_of__04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/removed_reflect_type_of/baml_tests__diagnostic_errors__removed_reflect_type_of__05_diagnostics.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/removed_reflect_type_of/baml_tests__diagnostic_errors__removed_reflect_type_of__10_formatter__main.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/self_in_body/baml_tests__diagnostic_errors__self_in_body__03_ppir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/self_in_body/baml_tests__diagnostic_errors__self_in_body__04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/self_in_body/baml_tests__diagnostic_errors__self_in_body__05_diagnostics.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/self_in_body/baml_tests__diagnostic_errors__self_in_body__10_formatter__main.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/type_reflection_strict/baml_tests__diagnostic_errors__type_reflection_strict__03_ppir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/type_reflection_strict/baml_tests__diagnostic_errors__type_reflection_strict__04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/type_reflection_strict/baml_tests__diagnostic_errors__type_reflection_strict__05_diagnostics.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/diagnostic_errors/type_reflection_strict/baml_tests__diagnostic_errors__type_reflection_strict__10_formatter__reflect_intrinsic_errors.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/src/compiler2_tir/snapshots/baml_tests__compiler2_tir__phase5__snapshot_baml_package_items.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_textual.snapis excluded by!**/*.snap
📒 Files selected for processing (73)
baml_language/crates/baml_builtins2/baml_std/baml/ns_llm/llm.bamlbaml_language/crates/baml_builtins2/baml_std/baml/ns_llm/llm_types.bamlbaml_language/crates/baml_builtins2/baml_std/baml/ns_reflect/reflect.bamlbaml_language/crates/baml_builtins2/baml_std/baml/ns_type/type.bamlbaml_language/crates/baml_builtins2/baml_std/baml/type_class.bamlbaml_language/crates/baml_builtins2/src/lib.rsbaml_language/crates/baml_compiler2_ast/src/lower_cst.rsbaml_language/crates/baml_compiler2_ast/src/lower_expr_body.rsbaml_language/crates/baml_compiler2_emit/src/lib.rsbaml_language/crates/baml_compiler2_hir/src/package.rsbaml_language/crates/baml_compiler2_mir/src/ir.rsbaml_language/crates/baml_compiler2_mir/src/lower.rsbaml_language/crates/baml_compiler2_ppir/src/lib.rsbaml_language/crates/baml_compiler2_tir/src/builder.rsbaml_language/crates/baml_compiler2_tir/src/infer_context.rsbaml_language/crates/baml_compiler2_tir/src/lower_type_expr.rsbaml_language/crates/baml_compiler2_tir/src/package_interface.rsbaml_language/crates/baml_compiler2_tir/src/resolve.rsbaml_language/crates/baml_compiler_parser/src/parser.rsbaml_language/crates/baml_lsp2_actions/src/check.rsbaml_language/crates/baml_lsp2_actions/src/completions.rsbaml_language/crates/baml_lsp2_actions/src/completions_tests.rsbaml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/interfaces_inferred_generic_type_args.bamlbaml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/stream_llm_inferred_typeargs.bamlbaml_language/crates/baml_tests/baml_src/ns_class_type_args_at_runtime/class_type_args_at_runtime.bamlbaml_language/crates/baml_tests/baml_src/ns_inferred_generic_type_args/inferred_generic_type_args.bamlbaml_language/crates/baml_tests/baml_src/ns_instantiation_expr/instantiation_expr.bamlbaml_language/crates/baml_tests/baml_src/ns_instantiation_expr/ns_qualified/q.bamlbaml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces.bamlbaml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces_2.bamlbaml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces_3.bamlbaml_language/crates/baml_tests/baml_src/ns_interfaces_associated_types/interfaces_associated_types.bamlbaml_language/crates/baml_tests/baml_src/ns_projection_patterns/projection_patterns.bamlbaml_language/crates/baml_tests/baml_src/ns_prompt_tag_runtime/prompt_tag_runtime.bamlbaml_language/crates/baml_tests/baml_src/ns_provider_stdlib/provider_stdlib.bamlbaml_language/crates/baml_tests/baml_src/ns_reflect_type_of/reflect_type_of.bamlbaml_language/crates/baml_tests/baml_src/ns_reflect_type_of_generic/reflect_type_of_generic.bamlbaml_language/crates/baml_tests/baml_src/ns_self_frame_slot/self_frame_slot.bamlbaml_language/crates/baml_tests/baml_src/ns_streaming_parsing/streaming_parsing.bamlbaml_language/crates/baml_tests/baml_src/ns_type_reflection/type_reflection.bamlbaml_language/crates/baml_tests/projects/compiles/reflect_shadowing/main.bamlbaml_language/crates/baml_tests/projects/compiles/reflect_type_of_user_generic/main.bamlbaml_language/crates/baml_tests/projects/compiles/stream_llm_inferred_typeargs/main.bamlbaml_language/crates/baml_tests/projects/diagnostic_errors/removed_reflect_type_of/main.bamlbaml_language/crates/baml_tests/projects/diagnostic_errors/self_in_body/main.bamlbaml_language/crates/baml_tests/projects/diagnostic_errors/type_reflection_strict/reflect_intrinsic_errors.bamlbaml_language/crates/baml_tests/src/compiler2_mir/mod.rsbaml_language/crates/baml_tests/tests/env.rsbaml_language/crates/baml_tests/tests/interfaces.rsbaml_language/crates/baml_tests/tests/interfaces_associated_types.rsbaml_language/crates/baml_tests/tests/prompt_tag_runtime.rsbaml_language/crates/baml_tests/tests/reflect_call_any.rsbaml_language/crates/baml_tests/tests/streaming_parsing.rsbaml_language/crates/baml_tests/tests/type_value_equality.rsbaml_language/crates/baml_type/src/template.rsbaml_language/crates/bex_engine/src/lib.rsbaml_language/crates/bex_engine/tests/generics_explicit.rsbaml_language/crates/bex_engine/tests/generics_inference.rsbaml_language/crates/bex_engine/tests/host_value_callable.rsbaml_language/crates/bex_vm/build.rsbaml_language/crates/bex_vm/src/lib.rsbaml_language/crates/bex_vm/src/package_baml/mod.rsbaml_language/crates/bex_vm/src/package_baml/reflect.rsbaml_language/crates/bex_vm/src/package_baml/type_class.rsbaml_language/crates/bex_vm/src/package_boundary/mod.rsbaml_language/crates/bex_vm/src/vm.rsbaml_language/crates/bex_vm_types/src/types/object.rsbaml_language/crates/bridge_ctypes/src/value_encode.rsbaml_language/sdk_tests/crates/csharp/phase6_slice/baml_src/ns_csharp_phase6/main.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_generic_tests/types.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_go_type_tests/main.bamlbaml_language/sdks/python/rust/sdkgen_python_pydantic2/src/routing.rsbaml_language/sdks/rust/bridge_rust/tests/live_engine.rs
💤 Files with no reviewable changes (3)
- baml_language/crates/bex_vm/src/lib.rs
- baml_language/crates/baml_builtins2/baml_std/baml/ns_reflect/reflect.baml
- baml_language/crates/bex_vm/build.rs
|
@coderabbitai review |
✅ Action performedReview finished.
|
…s1, PR 4) (#4331) **BEP-066 slice-1 stack, PR 4 of 5** — chained on #4330. Implements the ratified identity design (I-1/I-2/I-4/I-9): `type` values carry a mint token, and all three equality routes compare mints. ## Design - `Object::Type` → `Box<TypeValue { ty: RealizedTy, mint: MintId }>` (64-byte Object assert intact; no anchors/defs — slice 2). - `MintId::Static(u64)`: FNV-1a-64 (fixed offset/prime, big-endian numeric tokens) over `NormalTy::canonical` with the VM's program facts as TypeContext + a per-VM spelling-keyed digest cache — so `type.of<string?>() == type.of<string | null>()` and every reference to a static declaration shares one mint (I-2), process-independently. - `MintId::Runtime(u64)`: shared AtomicU64 on `BexHeap` (spawned VMs covered). No producer yet — the constructors land in slice 2; distinctness pinned at the Rust level. - `BexVm::alloc_static_type` is the single constructor — no site can forget the mint. Wire/FFI strip mints outbound, re-derive inbound (H-4: identity never crosses); `Program` borsh unchanged. ## The three eq routes, unified atomically `CmpOp::{Eq,NotEq}` (vm.rs) · `EqualsDriver` (ops.rs) · `baml.deep_equals` (root.rs) — all mint-only, plus `TypeValue::{PartialEq,Eq,Hash}`. Observable consequence, pinned by the flipped PR-1 characterization tests: permuted unions stay equal under `==` and **`deep_equals` flips false→true** (was syntactic). GC/deep-copy preserve the full TypeValue. ## Gates Full baml_tests (1,486 lib + all binaries + 2,633 CLI cases) · bex_vm 21 + load_type 5 · bex_heap · bex_engine 109 · bex_vm_types 42 · project 82 — all green. Touched-crate clippy `-D warnings`, fmt, rustdoc `-D warnings` clean. **Zero snapshot churn** (mint is invisible to compilation, as designed). Implemented by a Codex (gpt-5.6-sol) worker under stack-manager review. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added consistent identity handling for reflected `type` values. * Equivalent type definitions now share stable identities across evaluation, reflection, host calls, and serialization. * Static and runtime type identities are kept distinct where appropriate. * **Bug Fixes** * Updated deep equality so equivalent union types compare equal regardless of member order. * Ensured optional types and explicit nullable unions resolve to the same identity. * Preserved type identity through garbage collection and value conversion. * **Tests** * Expanded coverage for canonical type equality, reflection, serialization, and cross-runtime behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
BEP-066 slice-1 stack, PR 3 of 5 — chained on #4328.
What
reflectstops being a root package and becomes thebaml.reflectnamespace (manifest, deps, emit allowlist, native wiring folded into the baml package dispatch,ARG_FQNupdates). SDK routing needed nothing — no special cases existed; symbols route underbaml/automatically.reflect.…andtype.…in expression position re-resolve asbaml.…on full miss — one uniform rule mirrored through TIR, hover/semantic tokens, and completions. User names always shadow the shorthand (pinned by a corpus project including a user class namedreflect).type.of<T>()/type.of_value(v)via a carrier namespace (baml/ns_type/type.baml):ofis the existing compiler intrinsic re-keyed ("baml.type.of"),of_valuea new native overvalue_concrete_ty— fail-open to theunknowntype value for definition objects,throws never-honest; K-12 pinned (of_value(5)equalstype.of<int>()). Zero parser changes — expression-positiontype.of<…>()already parses; alias declarations are top-level-only, so the feared ambiguity is vacuous (pinned by parser tests).reflect.type_of(bare or qualified) hits a targeted funnel —`reflect.type_of` was renamed to `type.of` (BEP-066)— with no DiagnosticId discriminant shift. Every internal call site migrated in this commit (stdlib ×5 files, 16 baml_src suites, 4 projects, inline-Rust BAML in baml_tests + bex_engine, sdk fixtures, LSP fixtures).Gates
68 baml_tests binaries 0 failed · bex_vm 21/0 · tir 324/0 · LSP 468/0 (2 reviewed expectation updates) · project 82/0 · parser 154/0 · surface 17/0 · bytecode_cache 43/0 · workspace check clean. Snapshot accepts grouped by five causes in the commit message (stub-listing filter, new namespaces, FQN rendering, spelling migration, new projects).
Summary by CodeRabbit
New Features
type.of<T>()to obtain runtime type information.type.of_value(...)to derive runtime types from values, returningunknownwhen reconstruction is unavailable.bamlnamespace.Bug Fixes
Diagnostics
reflect.type_of<T>()usage withtype.of<T>().