From fe9d83ae3a07c4a1cbfd5338294935bd5b064ec0 Mon Sep 17 00:00:00 2001 From: Vasilev Dmitrii Date: Sun, 9 Aug 2026 02:25:10 +0700 Subject: [PATCH] fix(parser): BDD-style fns skipped; fpga-smoke fully green Closes #1960 The #1941 hardening surfaced constructs the parser silently dropped; this closes the fpga-smoke tail: - `fn name() given ... then ...` (a keyword-style test spelled as a fn, linker.t27) is recognized right after the parameter list, BEFORE return-type parsing -- otherwise `given` was consumed as an identifier return type and the body-brace check failed - partition.t27: a parameter named `module` (a keyword) renamed to mod_name fpga-build --smoke now generates all 31 modules + the wrapper and is GREEN again (it had been red since #1941 exposed the silently-dropped match statements, paren-less conditions and BDD forms). tri-net's 77-spec icarus gate is green; unit suite at the single pre-existing red. FROZEN_HASH resealed. Co-Authored-By: Claude Fable 5 --- NOW.md | 8 ++++++++ bootstrap/src/compiler.rs | 8 ++++++++ bootstrap/stage0/FROZEN_HASH | 2 +- docs/NOW.md | 8 ++++++++ specs/fpga/partition.t27 | 4 ++-- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/NOW.md b/NOW.md index 4d4c2e205..bb4d289d5 100644 --- a/NOW.md +++ b/NOW.md @@ -2,6 +2,14 @@ Last updated: 2026-08-08 +## parser: BDD-style fns skipped; fpga-smoke fully green (Closes #1960) + +- `fn name() given ... then ...` (a keyword-style test spelled as a fn, linker.t27) is now recognized BEFORE return-type parsing -- otherwise `given` was consumed as an identifier return type and the body brace check failed +- partition.t27: a parameter named `module` (a keyword) renamed to mod_name +- fpga-build --smoke: 31 modules + wrapper generate -- GREEN again (was red since the #1941 hardening surfaced the silently-dropped constructs) +- tri-net 77-spec icarus gate green; unit suite at the single pre-existing red +- FROZEN_HASH resealed + ## parser: braced if-expr arms, paren-less conditions, &-transparent types; fpga specs repaired (Refs #1960) - If-EXPRESSIONS accept braced arms (`if (c) { 2 } else { 0 }`); if/while STATEMENTS accept paren-less Rust-style conditions with the struct-literal-in-condition rule (a `{` after the cond opens the body) diff --git a/bootstrap/src/compiler.rs b/bootstrap/src/compiler.rs index ba8b26a0e..7199a2938 100644 --- a/bootstrap/src/compiler.rs +++ b/bootstrap/src/compiler.rs @@ -1771,6 +1771,14 @@ impl Parser { } self.expect(TokenKind::RParen)?; + // BDD-style fn: `fn name() given ... then ...` -- a keyword-style test + // spelled as a fn (linker.t27). Detect BEFORE return-type parsing, + // which would otherwise consume `given` as an identifier return type. + if self.current.kind == TokenKind::Ident && self.current.lexeme == "given" { + self.skip_to_next_top_level(); + return Ok(decl); + } + // Optional arrow for return type: -> Type if self.current.kind == TokenKind::Arrow { self.advance(); // consume -> diff --git a/bootstrap/stage0/FROZEN_HASH b/bootstrap/stage0/FROZEN_HASH index fdc30c525..c04f2309b 100644 --- a/bootstrap/stage0/FROZEN_HASH +++ b/bootstrap/stage0/FROZEN_HASH @@ -1 +1 @@ -ac0310ff69d2c211d638757eaa8704e80a968918ccb93f5fe4ebb353e99a3788 +8672ec556e8a02c016306dfce4aa73d843ad98ea08a0e75c032e049806bc6ff5 diff --git a/docs/NOW.md b/docs/NOW.md index d1a65a9bf..8e342f18d 100644 --- a/docs/NOW.md +++ b/docs/NOW.md @@ -2,6 +2,14 @@ Last updated: 2026-08-08 +## parser: BDD-style fns skipped; fpga-smoke fully green (Closes #1960) + +- `fn name() given ... then ...` (a keyword-style test spelled as a fn, linker.t27) is now recognized BEFORE return-type parsing -- otherwise `given` was consumed as an identifier return type and the body brace check failed +- partition.t27: a parameter named `module` (a keyword) renamed to mod_name +- fpga-build --smoke: 31 modules + wrapper generate -- GREEN again (was red since the #1941 hardening surfaced the silently-dropped constructs) +- tri-net 77-spec icarus gate green; unit suite at the single pre-existing red +- FROZEN_HASH resealed + ## parser: braced if-expr arms, paren-less conditions, &-transparent types; fpga specs repaired (Refs #1960) - If-EXPRESSIONS accept braced arms (`if (c) { 2 } else { 0 }`); if/while STATEMENTS accept paren-less Rust-style conditions with the struct-literal-in-condition rule (a `{` after the cond opens the body) diff --git a/specs/fpga/partition.t27 b/specs/fpga/partition.t27 index c3b5d8c9b..76854ccd6 100644 --- a/specs/fpga/partition.t27 +++ b/specs/fpga/partition.t27 @@ -81,9 +81,9 @@ module Partition { dsp48 : u32, } - fn assignment(module: &str, fpga: u32, luts: u32, ffs: u32, bram: u32, dsp: u32) -> PartitionAssign { + fn assignment(mod_name: &str, fpga: u32, luts: u32, ffs: u32, bram: u32, dsp: u32) -> PartitionAssign { return PartitionAssign{ - .module_name = module, + .module_name = mod_name, .fpga_idx = fpga, .luts = luts, .ffs = ffs,