Repository navigation
fix(check): say a def given <...> is a def, and how a do block opens - #1865
Conversation
A def written with a datatype's <...> arguments reported "a declared datatype (unknown: X)", though X is defined: it now says X is a def, applied as X(...). An unknown name keeps "unknown". A do block whose effect lacks its '<' expected only '<': it now shows the block written with the effect it names, do M<...>:. Neither is about IO, though `IO<Unit>` as a return type and `do IO(Unit):` are the common slips. From bendlang#1835, without its IO case. Co-Authored-By: Adeer Khan <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks, the general version is better than the IO special case. I merged it onto main d30d7dd: test 1729/1729, repo 54/54, ping 81/81 and safe (0 false rejects) all pass. Perf is noise (main misses cells on the same rerun). bend.ts goes from 44,067 to 44,135 ttok. The checker and parser behave correctly; these comments are only about what the new messages say.
|
…does The def case keeps "a declared datatype" and adds "Note: X is a def: write its arguments as ()", the mirror of the datatype note. Its name comes through name_show, so an imported def reads as the file spells it (L.Twice, not lib.Twice). The do block's hint drops a name_key that did nothing: m is the name as written. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…call A def with no parameters given <...> notes "write it as X": the slip is the arguments, and X(...) would only move it. An undefined X.bind or X.pure, the calls a do block on X desugars to, notes that the do block calls them, so a do block on a name with neither no longer fails on a name the user never wrote. The do header still checks nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks @Lorenzobattistela! Going through the points:
Test gate 1723/1723, repo 54/54. |
Two easy slips gave errors that didn't point at the fix:
The first reported
a declared datatype (unknown: IO), althoughIOis defined. The second reported onlyexpected '<'.Neither problem is specific to IO. Any def written as
X<...>hits the first, and anydo Mwithout its<hits the second. So instead of a special case for IO (as in #1835), both errors now come from what the name is and what was written:book_adt. A name in type position is either a datatype or a def. A def keepsa declared datatypeand addsNote: X is a def: write its arguments as (), the mirror of the existingNote: X is a datatype: write its arguments as <>. The name comes throughname_show, so an imported def reads as the file spells it (L.Twice, notlib.Twice). A def with no parameters notesNote: X is a def with no arguments: write it as Xinstead, since the slip is the<...>itself. An unknown name keeps(unknown: X).doparser. A missing<now reports'<' (a do block is written do M<...>:), with the effect the user wrote, whatever follows the name. The header checks nothing about the name..bind/.pure. Adoblock onMdesugars toM.bindandM.pure. When one is undefined, thea defined nameerror now notesa do block on M calls M.bind and M.pure, so the error no longer names only a call the user never wrote.Tests
tests/check/def_type_args.bend(new):Twice<U32>for a user-defineddef Twice(A: Type) -> Type.tests/parse/do_effect_parens.bend(new):do IO(Unit):, from fix(check): name the type and effect spellings of IO when one is used for the other #1835.tests/check/def_type_args_none.bend(new):Num<U32>fordef Num() -> Type.tests/parse/do_missing_param.bend:do Result:now pins the new message.tests/check/do_missing_bind.bend:do Box<>:with noBox.bindnow pins the note.What I ran
IO<Unit>as a return type reportsa declared datatypewithNote: IO is a def: write its arguments as ().as L, writtenL.Twice<U32>, getsNote: L.Twice is a def: ...(before this, it showed the internallib.Twice).Supersedes #1835 (thanks @adeerkhan, who is co-author on the commit).
🤖 Generated with Claude Code