Repository navigation
Say length(xs) to somebody who wrote xs.length() - #211
Merged
Merged
Conversation
A field access that names a function used to be answered as a missing
field:
error[DEED4004]: `List<Int>` has no field `length`
3 | fn f(xs: List<Int>) -> Int { xs.length() }
| ^^^^^^ no such field
`length` is right there. It is a function rather than a method, and the
message sends the reader off to look for a field that was never going to
exist, in a language where the thing they wanted is one rearrangement
away.
= note: there are no methods: `length` is a function and takes the
value as its first argument, so this is written `length(x)`
rather than `x.length()`
The note is only added when the name is a function in scope, so a
misspelled field is still a misspelled field and still gets the list of
what the record has. Telling the author of a typo to call it would be
worse than saying nothing.
No fix is offered. Turning `xs.length()` into `length(xs)` means moving
the receiver across the dot and into the argument list, and the
diagnostic here has the field's span and not the call's, so an edit built
from what is known at this point would be a guess about text it cannot
see.
onatozmenn
force-pushed
the
typeck/no-methods
branch
from
July 27, 2026 10:56
d4c0ae6 to
5f19871
Compare
This was referenced Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third one from the newcomer sweep.
xs.length()was answered as a missing field:lengthis right there, it's a function rather than a method, and the message sends the reader looking for a field that was never going to exist. Now:I checked that
lengthreally does work on a list before suggesting it,examples/proven.deed:25hastype NonEmptyList = List<Int> where length(value) > 0, so this isn't pointing at a dead end.The note only appears when the name is a function in scope. A misspelled field still gets the existing "it has
alpha" note and nothing about methods, since telling somebody with a typo to call it would be worse than saying nothing. There's a test for that direction too.No fix offered. Rewriting
xs.length()intolength(xs)means moving the receiver across the dot and into the argument list, and the diagnostic has the field's span, not the call's, so any edit built here would be a guess about text it can't see.Investigated with AI assistance.