Is your feature request related to a problem? Please describe.
Bare return can give the Lyte checker trouble, but it is unclear why -- unsupported syntax, incomplete feature, or a type-checking/codegen issue?
Describe the solution you'd like
If bare return is intentionally unsupported, Lyte should report a clearer error, such as "return requires an explicit value." It would also help to clarify the intended pattern for early exits.
Describe alternatives you've considered
I think it works to use explicit return values like return 0, return false, or return nil, which makes sense to Lyte's lean towards the literal. May simply need a clearer diagnostic and documentation.
Something like these are in play:
// 1. Bare return in a void helper: currently problematic
do_work() {
if done {
return
}
value = value + 1
}
// 2. Explicit return value in a value-returning helper: works as expected
clamp01(x: f32) -> f32 {
if x < 0.0 { return 0.0 }
if x > 1.0 { return 1.0 }
x
}
// 3. Branching workaround for void helpers
do_work_safe() {
if !done {
value = value + 1
}
}
Is your feature request related to a problem? Please describe.
Bare
returncan give the Lyte checker trouble, but it is unclear why -- unsupported syntax, incomplete feature, or a type-checking/codegen issue?Describe the solution you'd like
If bare
returnis intentionally unsupported, Lyte should report a clearer error, such as "returnrequires an explicit value." It would also help to clarify the intended pattern for early exits.Describe alternatives you've considered
I think it works to use explicit return values like
return 0,return false, orreturn nil, which makes sense to Lyte's lean towards the literal. May simply need a clearer diagnostic and documentation.Something like these are in play: