Repository navigation
feat(lang): add assert statements to Forma-Pipe - #133
Draft
farisbasha wants to merge 1 commit into
Draft
farisbasha wants to merge 1 commit into
farisbasha wants to merge 1 commit into
Conversation
`assert lhs <op> rhs [, "message"]` compares two number expressions (< <= > >= == !=). A false assert fails the script with both values, so the eval transaction rolls back. Comparison operators are only parsed inside assert. Adds a spec line and a GBNF rule. Refs wrong-nebula#132
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the first step proposed in #132 (craftsmanship blueprint item 2). Opened as a draft so the shape can be agreed there first; happy to change the syntax or error format.
What it adds
assert <expr> <op> <expr> [, "message"],opin<<=>>===!=. Both sides must be numbers, so it works withclearance(),section(), scalars and math.line 3: assert failed: gap too small: clearance(a, b) >= 1.5 (left 1, right 1.5)assert;x = 1 < 2is still an error.assertbecomes a built-in name fordef, but a part calledassert(assert = box(...)) still works.forma specgets one line, andgrammar/forma_pipe.gbnfgetsassert-stmtandcmp-oprules. The compact dialect is unchanged.Tests
crates/forma-lang/tests/assert_statement.rs(7 tests): passing asserts, each operator failing, the error text with message, rollback of the script's parts after a failure, malformed asserts, comparisons outsideassert, and spec/grammar entries.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: 164 passed, 0 failed (Linux). I did not run the npm/WASM smoke tests.This PR was prepared with AI assistance (Claude).