Commit 6a7dc25
Fix union encoding/decoding (#1898)
So there are a handful of union issues and this fixes some of them.
First, type aliases that point at classes, enums or unions were not
encoding properly. That is fixed by this PR.
Second, unions were not decoding properly. That is also fixed.
Third, type definitions that are unions are not decoding properly, not
yet fixed but the first two felt meaningful enough to put up.
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Fixes union encoding/decoding issues and adds recursive union test.
>
> - **Behavior**:
> - Fixes type alias encoding for classes, enums, and unions in
`cffi_generated.rs` and `ctypes.rs`.
> - Fixes union decoding in `types-unions.go.j2` by switching from
`ValueTypeIndex` to `VariantName`.
> - **Schema**:
> - Adds `variant_name` field to `CFFIValueUnionVariant` in `cffi.fbs`.
> - **Tests**:
> - Adds `recursive-union.baml` test file for recursive union testing.
> - **Misc**:
> - Updates `GoTypeAlias` in `generate_types.rs` to include `is_union`
and `is_baml_serializable` flags.
> - Modifies `EncodeUnion` function in `encode.go` to include
`variantName`.
>
> <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 7b1f7bc. You can
[customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
---------
Co-authored-by: hellovai <vbv@boundaryml.com>1 parent 8104859 commit 6a7dc25
57 files changed
Lines changed: 1695 additions & 279 deletions
File tree
- engine
- language_client_cffi
- src
- cffi
- types
- language_client_codegen/src/go
- templates
- language_client_go/pkg
- cffi
- integ-tests
- baml_src/test-files/functions/output
- go
- baml_client
- types
- openapi/baml_client
- python/baml_client
- react/baml_client
- react
- ruby/baml_client
- typescript-esm/baml_client
- typescript/baml_client
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2336 | 2336 | | |
2337 | 2337 | | |
2338 | 2338 | | |
2339 | | - | |
2340 | | - | |
2341 | | - | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
2342 | 2343 | | |
2343 | 2344 | | |
2344 | 2345 | | |
| |||
2353 | 2354 | | |
2354 | 2355 | | |
2355 | 2356 | | |
| 2357 | + | |
2356 | 2358 | | |
2357 | 2359 | | |
2358 | 2360 | | |
| |||
2366 | 2368 | | |
2367 | 2369 | | |
2368 | 2370 | | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
2369 | 2378 | | |
2370 | 2379 | | |
2371 | 2380 | | |
| |||
2396 | 2405 | | |
2397 | 2406 | | |
2398 | 2407 | | |
| 2408 | + | |
2399 | 2409 | | |
2400 | 2410 | | |
2401 | 2411 | | |
| |||
2405 | 2415 | | |
2406 | 2416 | | |
2407 | 2417 | | |
| 2418 | + | |
2408 | 2419 | | |
2409 | 2420 | | |
2410 | 2421 | | |
| |||
2414 | 2425 | | |
2415 | 2426 | | |
2416 | 2427 | | |
| 2428 | + | |
2417 | 2429 | | |
2418 | 2430 | | |
2419 | 2431 | | |
| |||
2431 | 2443 | | |
2432 | 2444 | | |
2433 | 2445 | | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
2434 | 2450 | | |
2435 | 2451 | | |
2436 | 2452 | | |
| |||
2461 | 2477 | | |
2462 | 2478 | | |
2463 | 2479 | | |
| 2480 | + | |
2464 | 2481 | | |
2465 | 2482 | | |
2466 | 2483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| 492 | + | |
492 | 493 | | |
493 | | - | |
494 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
495 | 497 | | |
496 | 498 | | |
497 | 499 | | |
498 | 500 | | |
499 | | - | |
| 501 | + | |
| 502 | + | |
500 | 503 | | |
501 | 504 | | |
502 | 505 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | 31 | | |
41 | 32 | | |
42 | 33 | | |
| |||
249 | 240 | | |
250 | 241 | | |
251 | 242 | | |
| 243 | + | |
| 244 | + | |
252 | 245 | | |
253 | 246 | | |
254 | 247 | | |
| |||
415 | 408 | | |
416 | 409 | | |
417 | 410 | | |
| 411 | + | |
418 | 412 | | |
419 | 413 | | |
420 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
421 | 417 | | |
422 | 418 | | |
423 | 419 | | |
| |||
Lines changed: 0 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | 32 | | |
42 | 33 | | |
43 | 34 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
81 | 100 | | |
Lines changed: 20 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | 74 | | |
80 | 75 | | |
| 76 | + | |
81 | 77 | | |
82 | 78 | | |
83 | 79 | | |
| |||
250 | 246 | | |
251 | 247 | | |
252 | 248 | | |
| 249 | + | |
253 | 250 | | |
254 | 251 | | |
255 | 252 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments