Skip to content

fix(expr): quote explicit symbol literal operands - #27

Draft
morsel-ray wants to merge 2 commits into
RayforceDB:masterfrom
morsel-ray:fix/rs26-symbol-literal
Draft

morsel-ray wants to merge 2 commits into
RayforceDB:masterfrom
morsel-ray:fix/rs26-symbol-literal

Conversation

@morsel-ray

Copy link
Copy Markdown

Fix

Expr::Lit(Value::sym("A")) currently lowers to a bare native SYM, which the evaluator/query compiler can interpret as a name. Emit an explicit (quote datum) only for actual SYM atoms. This preserves the symbol value without converting it to STR or changing attributes on the retained caller value.

Expr::Col, operation/call heads, STR/numeric literals and vector literals keep their existing lowering. This does not introduce general quoted-LIST support.

Regressions

  • Standalone symbol literal, explicit quote AST and unchanged original attributes.
  • An ambient binding with the same name must not replace the literal; col(...) must still resolve the binding.
  • WHERE with an undefined symbol name, an ambient same-name binding, a source column with that name, and a projection alias with that name. Check actual selected symbols, not only row count.
  • Keep the STR-operand and explicit-column controls, and leave SYM vectors unwrapped.

Validation I ran

Reproduced #26 on the supplied source pins: Rust 8dc87922, core override 870e0ecc, q 69b42105. The original example intentionally exited zero while printing Name: 'A' undefined; its STR case returned one row. Both new regression functions fail on the old production lowering (AST-shape assertion / Name error), not during compilation.

With this fix, cargo test -p rayforce --test expr (11/11) and cargo test -p rayforce --test query (12/12) pass for both:

  1. The supplied core override 870e0ecc.
  2. The default pinned core 3.0.1 / 0aa2d6af, through the actual vendored staging path with RAYFORCE_SRC unset.

Both used q 69b42105; the same standalone example now returns one row for both SYM and STR on both pairs. Its temporary source was kept as an external reproduction artifact; permanent coverage is in the two test modules.

Toolchain: Rust/Cargo 1.92.0, Clang/libclang 18 (not the reporter's 21). Dependencies were prepared into a captured lock, then Cargo ran offline. These are targeted source-pair tests, not a full Rust suite, MSRV 1.74, published-crate archive, real-q or sanitizer certification. No core/pin/dependency/version changes.

Fixes #26.

Lower only actual SYM atoms through quote so query/source names and ambient globals cannot capture Expr::Lit data. Do not mutate retained values or coerce SYM to STR. Preserve explicit Col references, vector literals and call heads; test standalone, global and projection/column collisions.
@morsel-ray
morsel-ray marked this pull request as draft November 6, 2026 21:52
@morsel-ray

Copy link
Copy Markdown
Author

I have put this back in draft, despite the green debug/release jobs. A separate compatibility check exposed a gap in my lowering: the public Operation::Set / Operation::Let literal-name position is consumed as raw syntax. The pre-change AST form returns 7; the new compiled form supplies a LIST and returns type: name must be a symbol. I reproduced both locally with the default pinned core. Explicit Quote also changes the returned AST shape and needs a deliberate context treatment.

The WHERE/name-collision regressions still pass, but they do not cover these special-form operand roles. I am keeping this out of merge readiness while refining the boundary; no default core behavior or STR coercion change is proposed.

@morsel-ray

Copy link
Copy Markdown
Author

@singaraiona, one API-contract choice before I take this out of draft.

My proposed compatibility scope is to preserve raw name operands for explicit Operation::Set/Let and the old syntax tree under Operation::Quote, while retaining strong SYM-literal protection in evaluated operands. If/Do/And/Or/Try must not get a blanket raw-syntax exemption.

The remaining boundary is arbitrary Expr::Call: its head can be a native special form, alias, lambda, or later rebound name. A head-spelling switch or inspection of the current binding cannot universally determine operand roles. I propose data-literal semantics for Call arguments, with callers using explicit name/syntax expressions (col(...) or a deliberately constructed raw Value AST) for macro-like natives and aliases. That would not preserve every previously working Call("set", [lit(SYM name), ...]) composition.

Is that bounded contract acceptable, or must those literal-name Call compositions also remain source-compatible? If the latter, I should design an explicit operand-role/syntax API rather than expand a spelling whitelist. I prefer preserving the explicit builtin Operations and documenting the dynamic Call boundary, but have not implemented or selected that policy on your behalf.

A header-flag-only shortcut is insufficient: a separate default-core control with a genuinely quoted SYM atom selected B instead of literal A when the source also had column A (same row count). Explicit quote ASTs prevent that capture. No STR coercion or native-core semantic change is proposed here.

This branch has not been deployed

No deployments
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.

Query filter with Value::sym literal resolves it as a name instead of a symbol value

1 participant