Skip to content

Answer null and and rather than guessing a nearby name - #213

Merged
onatozmenn merged 1 commit into
mainfrom
resolve/names-from-elsewhere
Jul 27, 2026
Merged

onatozmenn merged 1 commit into
mainfrom
resolve/names-from-elsewhere

Conversation

@onatozmenn

Copy link
Copy Markdown
Collaborator

Last batch from the newcomer sweep. An unresolved name gets a suggestion from edit distance, which is right for a typo and wrong for a word that belongs to another language:

error[DEED3001]: cannot find `null` in this scope
help: there is a `f` in scope
   | f

Applying that would swap the reader's mistake for a stranger one.

null, nil, undefined, None and none now say there's no empty value, and that something which might be absent is a Result or a choice with a variant for the absence. That's how examples/generic_types.deed:26 declares Option, so it isn't a dead end.

and, or and not are the same idea under a different spelling, so they get &&, || and ! with a machine-applicable fix. a and b was already reporting cannot find 'and' but it sat underneath a warning that the a on its own goes nowhere, so the first thing the reader met was an offer to write let _ = in front of their expression. deed fix now leaves a && b and the file checks clean, I ran that.

self and this get the no-methods rule, same thing xs.length() is told a layer up in #211.

Nothing here shadows anything, since a name that resolves never reaches this point. A program that declares its own and still has one and there's a test for that direction.

That's the sweep done except n as String (silent) and for i in 0..10 (DEED4022 doesn't mention there are no ranges). Both want a bit more thought about where the message belongs.

Investigated with AI assistance.

An unresolved name gets a suggestion from edit distance, which is right
for a typo and wrong for a word that belongs to another language. `null`
used to come back as:

    error[DEED3001]: cannot find `null` in this scope
    help: there is a `f` in scope
       | f

That is a confident answer to a question nobody asked, and applying it
would replace the reader's mistake with a stranger one.

`null`, `nil`, `undefined`, `None` and `none` now say there is no empty
value, and that something which might be absent is a `Result` or a
`choice` with a variant for the absence, which is how `Option` gets
declared when a program wants one.

`and`, `or` and `not` are the same idea under a different spelling, so
they get `&&`, `||` and `!` and a machine-applicable fix. `a and b` was
already reporting `cannot find 'and'`, but underneath a warning that the
`a` on its own goes nowhere, so the reader met the wrong message first
and it offered to write `let _ =` in front of their expression. Running
`deed fix` on that file now leaves `a && b`, and it checks clean.

`self` and `this` get the no-methods rule, which is the same thing
`xs.length()` is told a layer up.

None of this shadows anything. A name that resolves never reaches the
place this is decided, so a program that declares a function called `and`
still has one, and there is a test holding that down.
@onatozmenn
onatozmenn merged commit b2432af into main Jul 27, 2026
1 check passed
@onatozmenn
onatozmenn deleted the resolve/names-from-elsewhere branch July 27, 2026 11:06
onatozmenn added a commit that referenced this pull request Aug 2, 2026
A `where` clause holding `and` stopped at the word, answered with the block
that did not follow it, and then with a type error about a body the parser
never reached. The resolver has had the right answer since #213 and never got
to give it: a bare name is only an expression where a statement can start, and
a contract clause is not one. Counted across the eighteen recorded model runs,
the word reached the parser seventeen times and the resolver zero.

DEED2020 now. The word is read in the operator's position, with the operator's
precedence, so `n > 0 and n < 10 or n == 20` parses to the tree the symbols
would have given, the clause is the one that was written, and `deed fix` writes
the symbol.

`not` goes in front of a value rather than between two and still reaches the
resolver, which the resolver test now says.

Closes #865.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant