✓
Passing This code compiles and runs correctly.
Code
// A compound may name another compound: `pos: Position` expands to its
// scalar leaves, each keeping its identity — Health stays the shared
// terminal, raw leaves stay positional. Position sits FIRST, so expansion
// feeds synthesis its first leaf; without the walk the emitter would name
// an undeclared `Position` one stage later. The push value is f32-exact:
// pos.x is f32, and 98.6 is not representable there.
import std/io
import std/proto
import std/list
std/proto:f64(Health)
pub tor report-health { health: Health } -> Health
report-health -> health
std/proto(Position) {
x: f32
y: f32
}
std/proto(Player) {
pos: Position
health: Health
}
std/list:new(Player)
| list players |> std/list:push(xs: players, pos_x: 0.0, pos_y: 0.0, health: 98.5) |> std/list:pop(xs: players)
| item player |> report-health(player.health): player_out |> std/io:print.ln("player {{ player_out:d }}") |> std/list:free(xs: players)
| empty |> std/io:print.ln("player EMPTY") |> std/list:free(xs: players)
| err e |> std/io:print.ln("ERR {{ e:s }}")
Actual
player 98.5
Expected output
player 98.5
Flows
flow ~f64 click a branch to expand · @labels scroll to their anchor
f64 (expr: Health)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Position, source: x: f32
y: f32)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Player, source: pos: Position
health: Health)
flow ~new click a branch to expand · @labels scroll to their anchor
new (Player)
Test Configuration
MUST_RUN