Skip to content

fix(effects): scan CID/FID with the source's own comment rules - #1653

Open
adeerkhan wants to merge 1 commit into
bendlang:mainfrom
adeerkhan:fix/effect-comment-continuation
Open

adeerkhan wants to merge 1 commit into
bendlang:mainfrom
adeerkhan:fix/effect-comment-continuation

Conversation

@adeerkhan

Copy link
Copy Markdown

Resolves #1604.

The c_ids scanner resolved CID(k)/FID(k) by text over the whole effect source, but applied C's line-continuation rule to every source:

  • JS: a // comment ending in a backslash swallowed the next line, so a following io_eff(CID(...)) was left unresolved and the effect died at runtime with ReferenceError: CID is not defined.
  • CRLF C: the continuation pattern only matched \ + LF, so a CRLF // ... \ comment failed to splice, and a quoted CID(...) on the next line leaked out of the comment and failed the build.

Fix: splice a C source's backslash-newline (C's phase-2 line splice, \ + CR? LF) before scanning, and leave JS lines alone. The line-comment pattern now ends at the newline. This matches each host's real rules: C keeps a continuation inside a comment, JS does not.

Added a JS-lane regression test (tests/io/effect_comment_backslash): a // ... \ comment directly before io_eff(CID(answer), ...) — fails on the old scanner (unresolved CID), passes on the new one. Verified the scanner behavior against the previous implementation for the JS, CRLF-C, and LF-C cases.

The c_ids scanner applied C's backslash-newline continuation to every source,
so a JS `//` comment ending in a backslash swallowed the next line: a
following `io_eff(CID(...))` line was left unresolved and the effect died at
runtime (ReferenceError: CID is not defined). And it used `\\\n` for the
continuation, which misses a CRLF C comment (so a quoted CID leaked out of a
C comment and failed the build).

Splice a C source's backslash-newline (line continuation) before scanning and
leave JS lines alone, and change the line-comment pattern to end at the
newline. Resolves bendlang#1604.
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.

Foreign effect ID scanning uses the wrong line-continuation rules

1 participant