Skip to content

Add break/continue/return jump statements (VAMS-2023) - #26

Merged
sai-v-ch merged 2 commits into
OpenVAF:mobfrom
sai-v-ch:vams2023-jumps
Aug 1, 2026
Merged

Add break/continue/return jump statements (VAMS-2023)#26
sai-v-ch merged 2 commits into
OpenVAF:mobfrom
sai-v-ch:vams2023-jumps

Conversation

@sai-v-ch

Copy link
Copy Markdown
Collaborator

Summary

  • Implements VAMS-2023 §5.11 jump statements: break, continue, and return.
  • break/continue are allowed in while loops; rejected outside loops and inside analog for (§5.9.3).
  • return expr; is allowed only in analog user-defined functions and requires a value of the function return type (§4.7.2.2).
  • MIR lowering uses loop continue/break targets and a function exit block (only when the body contains return).
  • Part of the VAMS-2023 alignment tracked in Align with Verilog-AMS VAMS-2023 (Feb 2024): scope analysis and offer to implement #19.

Test plan

  • cargo test -p hir --test data_tests ui (includes new vams2023_jumps UI diagnostics)
  • cargo test -p hir_lower --test data_tests mir (includes new vams2023_jumps MIR snapshot)
  • cargo test -p parser -p hir_def -p hir_ty
  • cargo fmt on touched crates

Made with Cursor

Implement §5.11 jump statements: break/continue in while loops (banned in
analog for), and return with a value from analog user-defined functions,
with CFG lowering and validation diagnostics.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sai-v-ch
sai-v-ch merged commit 2763870 into OpenVAF:mob Aug 1, 2026
11 checks passed
sai-v-ch added a commit to sai-v-ch/OpenVAF-Reloaded that referenced this pull request Aug 1, 2026
Resolves the overlap with OpenVAF#26 (break/continue/return): both branches add
statement kinds to hir_def::Stmt and hir::Stmt and arms to every match
over them, so each conflict is a union of the two sides.

- hir_def::Stmt: EventTrigger alongside Break/Continue/Return; Break and
  Continue join the no-child-expression arm of walk_child_exprs, while
  EventControl needs its own arm for Event::Named.
- hir::Stmt, hir_lower::collect_cross_assigned, hir_ty::infere_stmt and
  the parser's STMT_TS: union.
- The two generated files (tokens/parser/generated.rs,
  syntax/ast/generated/nodes.rs) were regenerated from the cleanly merged
  ungram and KINDS_SRC rather than merged by hand.
@sai-v-ch
sai-v-ch deleted the vams2023-jumps branch August 1, 2026 03:47
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.

1 participant