Skip to content

CID scanning rewrites suffixes of legal host identifiers #1712

Closed

Description

@oxura

The effect scanner's ASCII word boundary treats CID inside legal host identifiers as the CID macro. On e5527d5, calling $CID(20) or πCID(20) fails compilation with Error: CID(20) names no constructor or def. JavaScript private #CID and identifiers containing a joiner have the same problem.

The patch requires a complete host identifier token, including Unicode ID_Continue, dollar, private-name and join-control boundaries. Comments and literals keep the existing scanner behavior; this is separate from #1604/#1653's line-continuation fix.

Real behavior proof: tests/io/effect_identifier_boundary.bend fails before in both C and JS builds. Afterward the actual native executable and Bun script each print 42. The JS program exercises dollar, Greek, private and joiner identifiers; the C program exercises dollar and Greek identifiers. Real CID(answer) registration still works.

Commands: bun bend2/main.ts tests/io/effect_identifier_boundary.bend -o boundary; ./boundary --threads 1 --gpu off; bun bend2/main.ts tests/io/effect_identifier_boundary.bend -o boundary.js; bun boundary.js.

Patch: oxura@7e2e021

Standalone sources
# CID is a macro token, not a suffix of a legal host identifier.
import Base

def answer() -> IO(U32):
  import "./effect_identifier_boundary.c"
  import "./effect_identifier_boundary.js"

def main() -> IO(Unit):
  do IO<Unit>:
    value : U32 <- answer()
    IO.print(U32.show(value))

#|42
static Term $CID(Term n) { return n + 1; }
static Term πCID(Term n) { return n + 1; }

static Term answer_run(Env e, Term* f, IoWork* w) {
  (void)e;
  (void)f;
  (void)w;
  return $CID(20) + πCID(20);
}

static void __attribute__((constructor)) answer_use(void) {
  io_eff(CID(answer), answer_run);
}
function $CID(n) { return n + 1; }
function πCID(n) { return n + 1; }
function joined‍CID(n) { return n + 1; }
class Counter {
  #CID(n) { return n + 1; }
  value() { return this.#CID(10); }
}
function answer() {
  return $CID(9) + πCID(10) + joined‍CID(9) + new Counter().value();
}
io_eff(CID(answer), answer);
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