mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
33 lines
481 B
Plaintext
33 lines
481 B
Plaintext
module repro;
|
|
|
|
import std::io;
|
|
|
|
interface VeryOptional
|
|
{
|
|
fn void do_something() @optional;
|
|
}
|
|
|
|
struct Foo (VeryOptional)
|
|
{
|
|
String name;
|
|
}
|
|
|
|
Foo foo = { "Foo" };
|
|
|
|
fn VeryOptional? get_very_optional()
|
|
{
|
|
return &foo;
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
VeryOptional? v = get_very_optional();
|
|
if (&v.do_something) // #error: expression may not be an optional
|
|
{
|
|
v.do_something();
|
|
}
|
|
else
|
|
{
|
|
io::printfn("do_something is not implemented for Foo");
|
|
}
|
|
} |