Skip to content

[A10] Define compiler intrinsics by binding provenance, not spelling #1209

Description

@SisyphusZheng

A10.1

[A10] Define compiler intrinsics by binding provenance, not spelling

Problem

The compiler recognizes intrinsics by identifier spelling (getText(sf)), not by import provenance. Evidence at baseline 2936bf0a:

  • @element: packages/adapter-vite/src/internal/compiler/semantic-core/compile.ts:1659,1694expr.expression.getText(sf) === 'element', no module check.
  • extends OpenElement: compile.ts:1772 — spelling only; hasRuntimeOpenElementImport (compile.ts:1514-1529) is used only to decide import injection (:1924-1926), never to validate heritage provenance.
  • @property: compile.ts:1283; computed(...): compile.ts:295 (hasRuntimeNamedImport :1532-1539 matches a named import from any module); trustedHtml(...): compile.ts:231-239 no import check at all; defineIslandConfig: compile.ts:1505.
  • Multiple recognizers that disagree: substring prefilter compiler/plugin.ts:27,41-43; dual-mode admission semantic-core/module-analysis.ts:131-167 (bare spelling or provenance); compile/lowering spelling-only.
  • No hostile fixtures exist; existing suites actively rely on spelling (declare function element(...) in compiled-element-v1.test.ts and others).

Decision

Compiler intrinsics are binding identities / provenance, not accidental identifier spelling. The compiler semantic core stays bundler-neutral (ADR-0148); no language semantics move into Vite.

Required hostile fixtures

Canonical + aliased OpenElement import; canonical + aliased decorator import; unrelated third-party function named element; unrelated class named OpenElement; lexical shadowing of element/property/computed/OpenElement; type-only imports; namespace imports; duplicate/conflicting bindings; local same-name functions/classes; supported re-export provenance (if intended); unsupported/ambiguous provenance must fail closed.

Acceptance

  • Hostile tests green; no accidental same-name symbol enters the OE language grammar.
  • Canonical aliases work if intentionally supported.
  • One canonical intrinsic-binding model conceptually used by compile/lowering, module analysis, and diagnostics; no second spelling-based recognizer survives.
  • Semantic core remains free of Vite/Rollup imports (pinned by compiler-semantic-core-boundary.test.ts).

Scope / non-goals

No Vite-specific semantics; no public compiler package. Existing spelling-dependent fixtures must be migrated to real imports.

Risk

High churn in compiler test fixtures; dev/HMR admission behavior changes for edge-case user code that accidentally used bare spellings.

Semantic owner: compiler semantic core (adapter-vite/src/internal/compiler/semantic-core/). Part of umbrella #1155. Internal Alpha.10 — no publish, no tag.

Activity

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

    P0adapter-vitealpha.10v0.42.0-alpha.10 audit remediation task trainrelease-blockerMust close before the target release can be promotedv0.44v0.44 compiled OpenElement architecture train

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions