unuesd constructor value yields opaque errors
Hjagu09 opened this issue · comments
The easiest way to describe this is just with some example code:
struct foo:
bar: int
constructor foo(bar: int = 1):
return foo{bar}
def baz():
return foo(5)
baz()
output
constructor.lobster(4): error: constructor must return value of its own type
in constructor.lobster(7): foo(bar:int)
in constructor.lobster(9): baz()
working code
struct foo:
bar: int
constructor foo(bar: int = 1):
return foo{bar}
def baz():
return foo(5)
print baz()
output
foo{5}
expected output
i would like the newly constructed value to be discarded as if i called a function (aka the first example outputs nothing), like what this code does
struct foo:
bar: int
constructor foo(bar: int = 1):
return foo{bar}
def baz():
return foo(5)
let _ = baz()
output
Yeah, it specializes the constructor to return void
in this case :)
Fixed here: 3f1ad74