Skip to content

fix(check): name the type and effect spellings of IO when one is used for the other - #1835

Open
adeerkhan wants to merge 1 commit into
bendlang:mainfrom
adeerkhan:fix/io-effect-spelling
Open

adeerkhan wants to merge 1 commit into
bendlang:mainfrom
adeerkhan:fix/io-effect-spelling

Conversation

@adeerkhan

Copy link
Copy Markdown
Contributor

Two spellings of IO are easy to swap, and each one reported an error that
never named the other:

import Base

def main() -> IO<Unit>:
  do IO<Unit>:
    IO.print("hello")
Error:
- message  : a declared datatype (unknown: IO)
Location: main
3>| def main() -> IO<Unit>:
  |               ^^^^^^^

The reverse, do IO(Unit):, reported only expected '<' / observed '('.

IO is a base def, not an ADT, so a type written IO<...> fell through to the
"unknown datatype" message; and the do parser expected < without saying
what it was for. Both now name the pair and the position:

  • a return type: a type: IO<...>is the do block's effect syntax; a return type is writtenIO(...)``
  • a do block: an effect's arguments in <...>(a do block isdo IO<...>:, and the type is written IO(...))

The two tests pin both messages and exit 1:

  • tests/check/io_effect_in_return_type.bend
  • tests/parse/do_effect_type_spelling.bend

What I ran: the source compiler (bun bend2/main.ts) on both tests (output
matches the pinned #| lines), gates/repo.ts --gate (PASS 54/54), and a valid
IO(Unit) / do IO<Unit> program (prints hi). gates/test.ts needs the
cluster and BEND_HOC is not set here, so I did not run the full test gate; CI
will.

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