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
{{ message }}
Repository navigation
c = s[i] on a string warns 'unresolved type in codegen, defaulting to int' #3479
Binding one byte of a string to a local warns, and the local is typed by a default:
main() {
s = "A"
c = s[0]
println(c)
}
warning: unresolved type in codegen, defaulting to int
--> b.ae:3:5
3 | c = s[0]
It then prints 65. A string parameter does the same (c = text[i]).
Expected: no warning. s[i] reads one byte (language reference, strings), so c gets the type that read has, as c = xs[0] does for an array. The default happens to give the right value here, but a typecheck that leaves a local's type to codegen is the failure, and the warning fails make check-examples, which builds every example with warnings as errors.
Found writing the Rosetta Code tranche of #1191 (PR #3477): Caesar cipher (c = text[i] and then match c { 65..=90 -> ... }) waits for it. Filed for the next batch.
Activity
examples: a first Rosetta Code tranche, measured against Go and Python (
fix: s[i] on a string is a checked byte (#3479)
fix: s[i] on a string is an int from 0 to 255; s[length] is the termi…
fix: a panic while a return inside a try computes its value is caught