aboutsummaryrefslogtreecommitdiff
path: root/testsuite/compilable/generic_arguments.elna
blob: 7312efe22392fa36e6994051bbff5e44adfe9cb1 (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(^Word8) * 2u);
  assert(#offset(Pair#[File, Word8], value) = #size(^Word8));
  assert(first#[File, Word8](@entry) = entry.key)
end.