verifier: account finite anonymous type sizes exactly

This commit is contained in:
dev committed 2026-10-09 13:26:17 +03:00
1 parent 03614c9bef
commit 111a3861f9
16 files changed
+226 -8

No files matched your search

@@ -0,0 +1,29 @@
; The nested array requires exactly 32 accounted bytes.
; expect: run
; result: 0
; grant: heap=mem.alloc:31
; fuel: 100
; phase: 2
; spec: docs/spec/03-memory-model.md §19; docs/spec/08-verifier.md §7.1
module test.nested_heap_size
air 0
lang 0.1
features [arrays, capabilities, effects, heap, ownership, resources]
type @Record = struct { data: array<array<u64, 2>, 2> }
fn @main(%heap: cap<mem.alloc>) -> u64
effects [mem.alloc]
entry:
%v = const.u64 7
%inner = array.splat array<u64, 2> %v
%outer = array.splat array<array<u64, 2>, 2> %inner
%record = struct.make @Record(%outer)
own.new %record, %heap, ok -> @ok, err -> @err
ok(%owned: own<@Record>):
own.free %owned
%yes = const.u64 1
ret %yes
err(%e: alloc_error):
%no = const.u64 0
ret %no
@@ -0,0 +1,29 @@
; The nested array requires exactly 32 accounted bytes.
; expect: run
; result: 1
; grant: heap=mem.alloc:32
; fuel: 100
; phase: 2
; spec: docs/spec/03-memory-model.md §19; docs/spec/08-verifier.md §7.1
module test.nested_heap_size
air 0
lang 0.1
features [arrays, capabilities, effects, heap, ownership, resources]
type @Record = struct { data: array<array<u64, 2>, 2> }
fn @main(%heap: cap<mem.alloc>) -> u64
effects [mem.alloc]
entry:
%v = const.u64 7
%inner = array.splat array<u64, 2> %v
%outer = array.splat array<array<u64, 2>, 2> %inner
%record = struct.make @Record(%outer)
own.new %record, %heap, ok -> @ok, err -> @err
ok(%owned: own<@Record>):
own.free %owned
%yes = const.u64 1
ret %yes
err(%e: alloc_error):
%no = const.u64 0
ret %no