umka-lang
umka-lang copied to clipboard
Allow implicit type casts for expression list items
import (
"th.um"
f = "font.um"
"std.um"
)
type Font* = interface {
validate(): bool
draw(text: str, pos: th::Vf2, color: uint32, scale: th::fu = 1.0)
measure(text: str): th::Vf2
}
fn load*(path: str, size: th::fu, filter: f::Filter = .linear): (Font, std::Err) {
return f::load(path, size, filter)
}
In load, there will be an error because f::Font to Font (interface) is not implicitly converted, the workaround is:
fn load*(path: str, size: th::fu, filter: f::Filter = .linear): (Font, std::Err) {
font, err := f::load(path, size, filter)
return font, err
}
In fact, this is not about interfaces:
fn f(): (int, int) {
return 5, 7
}
fn g(): (int, real) {
return f() // Incompatible types { int real } and { int int }
}
fn main() {
a, b := g()
printf("%v %v\n", a, b)
}
interesting