You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A function returning both result and fixed array can't use as last return ! since fixed array values won't be correct. Omitting ! is a workaround working by now, though is confusing and is hard to debug lines like this.
Reproduction Steps
importstrconvpub fnvalid_triangle(a u8, b u8, c u8) ![3]u8 {
ifint(a) +int(b) <=int(c) {
returnerror('Invalid: a + b <= c')
}
ifint(b) +int(c) <=int(a) {
returnerror('Invalid: b + c <= a')
}
ifint(c) +int(a) <=int(b) {
returnerror('Invalid: c + a <= b')
}
return [a, b, c]!
}
pub fntriangle_from_string(sides string) ![3]u8 {
s:= sides.split(',')
if s.len !=3 {
returnerror('Invalid: number of sides')
}
a:= strconv.atou8(s[0])!b:= strconv.atou8(s[1])!c:= strconv.atou8(s[2])!// warning: don't append `!` to next call // will confuse with fixed and return `garbage`.returnvalid_triangle(a, b, c)!
}
fnmain() {
dump(triangle_from_string('3,4,5')!)
}
Describe the bug
A function returning both result and fixed array can't use as last return
!since fixed array values won't be correct. Omitting!is a workaround working by now, though is confusing and is hard to debug lines like this.Reproduction Steps
Expected Behavior
Current Behavior
where 192 is random
Possible Solution
No response
Additional Information/Context
A workaround is omit
!in last line of methodtriangle_from_stringV version
V 0.4.12 dc0b0f5
Environment details (OS name and version, etc.)
https://play.vlang.io/p/a9ae34e637
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.