Skip to content

Foreign effect ID scanning uses the wrong line-continuation rules #1604

Closed

Description

@oxura

I hit this on main (234cb9b) while returning a constructor from a foreign effect. The source scanner uses C backslash continuation rules for JS comments, but misses C continuations when the file uses CRLF.

For an effect returning Maybe<&1, U32>, this valid JS fails at runtime with ReferenceError: CID is not defined:

function probe() {
  // A path ending in backslash: C:\
  return { $: CID(Some), value: 42 };
}
io_eff(CID(probe), probe);

With CRLF line endings, this valid C comment instead makes compilation fail with CID(NotASymbol) names no constructor or def:

// A quoted macro example: \
CID(NotASymbol)

The C preprocessor keeps the second line in the comment. JS does not: its comment ends at the first newline even when preceded by a backslash. The scanner currently gets both cases backwards. C also allows a CID token itself to be split with backslash-newline; that remains unreplaced and clang rejects it.

I have a small fix that splices C lines before scanning and leaves JS lines alone, plus a regression exercising real constructor returns on both backends. AI-assisted investigation and patch.

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