feat: execute tagged-union matches in type procedures
Preserve resolver failures on synthetic selector captures before elaborating payloads; selector bodies omit the original capture uses. Verified bro build, bro test (250 passed), and tests/native.py (536 interpreter/native programs at -O0 and -O2, allocator, LLVM and CLI checks).
This commit is contained in:
@@ -116,6 +116,15 @@ recompiles_specialized_calls_without_borrowing_previous_ir test {
|
||||
` }
|
||||
`}
|
||||
`Token proc($value Packet) type { return struct {} }
|
||||
`Captured proc(choice Choice) type {
|
||||
` match choice {
|
||||
` .payload |detail|: return struct {
|
||||
` values [match detail.text.len { 2: usize(2), else: usize(0) }]i16
|
||||
` bias i16 = match choice { .payload |selected|: selected.values[1], .empty: 0 }
|
||||
` },
|
||||
` .empty: return bool,
|
||||
` }
|
||||
`}
|
||||
`main proc() i16 {
|
||||
` if $(i16 != i16) { return $(i8(128)) }
|
||||
` values :: $(data())
|
||||
@@ -124,6 +133,8 @@ recompiles_specialized_calls_without_borrowing_previous_ir test {
|
||||
` same Fixed(2) :: fixed
|
||||
` packet :: $(packet_data())
|
||||
` if (Token(packet_data()) != Token(packet)) return 0
|
||||
` captured Captured(packet.choices[0]) :: { values = [19, 21] }
|
||||
` if (captured.values[0] + captured.values[1] + captured.bias != 42) return 0
|
||||
` payload :: packet.choices[0].payload
|
||||
` if (payload.values[0] != 40 or payload.values[1] != 2 or payload.text.len != 2) return 0
|
||||
` match packet.choices[1] { .empty: {}, .payload: return 0 }
|
||||
|
||||
Reference in New Issue
Block a user