You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue #1050
Added support for enums and literal strings in map keys:
```baml
enum MapKey {
A
B
C
}
class Fields {
// Enum as key
e map<MapKey, string>
// Single literal as key
l1 map<"literal", string>
// Union of literals as keys
l2 map<"one" | "two" | ("three" | "four"), string>
}
```
Literal integers are more complicated since they require maps to support
int keys. See #1180.
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Add support for enums and literal strings as map keys in BAML, with
updated validation, coercion logic, and tests.
>
> - **Behavior**:
> - Support for enums and literal strings as map keys added in `mod.rs`
and `types.rs`.
> - Validation logic updated to allow enums and literal strings as map
keys.
> - Coercion logic updated to handle enums and literal strings as map
keys.
> - **Tests**:
> - Added tests in `map_enums_and_literals.baml` and `map_types.baml` to
verify new map key functionality.
> - Updated `test_functions.py` and `integ-tests.test.ts` to include
cases for enum and literal string map keys.
> - **Misc**:
> - Updated error messages in `error.rs` to reflect new map key types.
> - Minor updates in `async_client.py`, `sync_client.py`, and
`client.rb` to support new map key types.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for c7742fd. It will automatically
update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
0 commit comments