summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/types/optional-ifoo.slang
blob: d2c9b6a5085bb9d0b9e8364af26fa6670d9c2d5e (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
//TEST:INTERPRET(filecheck=CHECK):

interface IFoo
{
    int get_result();
}

struct FooImpl : IFoo
{
    int get_result() { return data; }
    int data;
}

Optional<IFoo> generate_foo(int i)
{
    FooImpl result = {};
    result.data = i;
    return { result };
}

void main()
{
    // CHECK: hasValue: 1
    let result_foo = generate_foo(100);
    printf("hasValue: %d\n", (int)result_foo.hasValue);
}