Skip to content

fix(lang): reject reserved constant assignment and diagnose bare selector final assignment (Fixes #96) - #100

Merged
wrong-nebula merged 2 commits into
wrong-nebula:mainfrom
onlinegill:fix/lang-pi-and-selector-assignment
Dec 4, 2026
Merged

wrong-nebula merged 2 commits into
wrong-nebula:mainfrom
onlinegill:fix/lang-pi-and-selector-assignment

Conversation

@onlinegill

Copy link
Copy Markdown
Contributor

Summary

Fixes two silent gotchas in Forma-Pipe (crates/forma-lang/src/pipeline.rs, Fixes #96):

  1. Reserved constants (pi, PI, true, True, false, False): Rejects assigning to built-in constants in parse_stmt (cannot assign to built-in constant '...') so pi = box(...) fails loudly instead of creating an unreferenceable part.
  2. Bare selector keyword as final assignment: Tracks when the final statement is name = <bare selector keyword> (e.g. result = all). Under strict_manifold == true (--strict), returns an explicit error naming the selector and fallback part instead of silently exporting the previous part; under --no-strict, emits a WARN. Intermediate selector variables followed by mesh statements continue to work.

Verification

  • Added reserved_constant_assignment_rejected_and_bare_selector_last_assignment_diagnosed in crates/forma-lang/tests/audit_regressions.rs.
  • cargo test --locked --release -p forma-core -p forma-lang -p forma-cli -p forma-mcp -p forma-server -- --skip test_10000_fuzzed_modeling_operations_zero_crashes_zero_nans: all passed.
  • npm run build:wasm && npm test: 5/5 passed.

# Conflicts:
#	crates/forma-lang/tests/audit_regressions.rs
@wrong-nebula
wrong-nebula merged commit 75e705d into wrong-nebula:main Dec 4, 2026
3 checks passed
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.

A part named pi cannot be referenced, and result = all succeeds without making a part, so the previous part is exported

2 participants