Skip to content

[Medium] assert()/echo() not supported as chainable expressions #109

Description

@particlesector

Location: src/lang/Interpreter.cpp (Interpreter::evaluate), src/csg/CsgEvaluator.cpp (existing statement-form dispatch).

Real OpenSCAD (since 2019.05) allows assert()/echo() in expression position, most commonly for inline validation at the top of a function body:

function f(x) = assert(x > 0, "must be positive") x * 2;

ChiselCAD currently only supports both as statements — dispatched in CsgEvaluator, which owns the diagnostics/echo-message sink. A function body only ever reaches Interpreter::evaluate, which has no diagnostic channel at all today, so this isn't a small callBuiltin addition — it needs a diagnostics/echo sink threaded through every Interpreter::evaluate call site.

Why this matters for real-world scripts: this pattern is common in library code (e.g. BOSL2-style parameter validation) that guards a function's inputs before computing. A script that uses a library written this way will fail wherever the library relies on it.

Originally noted as a deferred gap in docs/roadmap.md (now trimmed); filing as a tracked issue instead.

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

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions