Lavash.Transformers.ValidateDsl (Lavash v0.3.0-rc.5)

Copy Markdown View Source

Compile-time validation of cross-entity references in the DSL.

Catches a family of "typo or stale reference" errors that would otherwise surface as a runtime crash, a silent nil, or a quiet shadow — usually deep inside lavash's runtime where the user can't easily trace them back to the original mistake. Each check raises Spark.Error.DslError with the offending entity name and a hint at the fix.

Run after Lavash.Transformers.ExpandFields (so all synthesized entities — animated phase states, setter actions, etc. — are present) and before any compile transformer.

Checks:

  1. state name uniqueness — two state :foo, ... declarations are a silent shadow (second wins).
  2. calculate name uniqueness — two calculate :foo, ... likewise.
  3. state/calculate name collision — a calculation with the same name as a state silently masks the state.
  4. action name uniqueness — duplicate action :foo do ... end silently keeps only one.
  5. reads [:field] — references must match a state OR calculation. Today this surfaces as KeyError inside the run body.
  6. set :field, ... — target must be a declared state.
  7. set ..., rx(@field) deps — references inside rx must match declared states or calculations. Today an unknown @field evaluates to nil silently.
  8. calculate :foo, rx(@field) deps — same shape as #7.
  9. Action guards (action :foo, [], [:guard]) — guard names must match a declared boolean state or calculation.

Summary

Functions

after?(arg1)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(arg1)

Callback implementation for Spark.Dsl.Transformer.before?/1.

transform(dsl_state)

Callback implementation for Spark.Dsl.Transformer.transform/1.