8000 A syntax error in a stdlib file surfaces as cascading prelude type errors · Issue #165 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

A syntax error in a stdlib file surfaces as cascading prelude type errors #165

Closed

Description

@akoskovacs

Writing if cond do a else b end (the do form, which the parser rejects in favour of then) inside a block in src/stdlib/string.kex did not produce the syntax error the same code produces in a user file. Instead the make String block was silently cut short at that point and the prelude interface check reported a wall of unrelated nonsense:

error: prelude interface: src/stdlib/time.kex:141:23: `at` expects argument 1 to be Range, but got String
error: prelude interface: src/stdlib/time.kex:145:29: `replace` expects 2 argument(s), got 3
error: prelude interface: src/stdlib/parsing.kex:28:36: `count` expects argument 1 to be Range, but got String
...

Every one of those is a String method that had vanished from the truncated make String block. Nothing pointed at string.kex at all, and the actual message ("use 'then' instead of 'do' in if expression") only appeared after extracting the function into a scratch .kex file.

Two things to look at:

  • the parser recovering from that error by consuming the enclosing end, so the rest of a make block is dropped instead of the error being reported;
  • the prelude build reporting downstream type errors when the stdlib source it just parsed produced diagnostics — those should be surfaced first and abort.

Activity

  1. akoskovacs commented on Sep 24, 2026

    @akoskovacs
    CollaboratorAuthor

    Fixed in #396: the prelude build reports stdlib parse errors first (naming the file) and aborts before analysis, and if ... do is reported once and parsed as then, so it no longer consumes the enclosing block's end. Regression: spec/error_if_with_do_in_make.kex.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0