aboutsummaryrefslogtreecommitdiff
path: root/testsuite/compilable/generic_arguments.elna
blob: 4d33db557678813a5b2ec549c3d9e608e33048ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
program()
type
  File = record
    fd: Int
  end

  Pair#[K, V] = record
    key: K;
    value: V
  end

var
  entry: Pair#[^File, ^Word8]

proc allocate#[T](size: Word) -> T
extern

proc first#[K, V](entry_ptr: ^Pair#[K, V]) -> K
return entry_ptr^.key

begin
  entry.key := allocate#[^File](#size(File));
  assert(#size(Pair#[^File, ^Word8]) = #size(Pointer) * 2u);
  assert(#offset(Pair#[^File, ^Word8], value) = #size(Pointer));
  assert(first#[^File, ^Word8](@entry) = entry.key)
end.