haskell: Phase 17 — import declarations anywhere among top-level decls
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
hk-collect-module-body previously ran a fixed import-loop at the start and then a separate decl-loop; merged into a single hk-body-step dispatcher that routes `import` to the imports list and everything else to hk-parse-decl. Both call sites (initial step + post-semicolon loop) use the dispatcher. The eval side reads imports as a list (not by AST position) so mid-stream imports feed into hk-bind-decls! unchanged. tests/parse-extras.sx 12 → 17: very-top, mid-stream, post-main, two-imports-different-positions, unqualified-mid-file. Regression sweep clean: eval 66/0, exceptions 14/0, typecheck 15/0, records 14/0, ioref 13/0, map 26/0, set 17/0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -320,7 +320,7 @@ larger conformance programs and removes one-line workarounds in test sources.
|
||||
`return (42 :: Int)`. Parser currently rejects `::` in `aexp` position;
|
||||
desugar should drop the annotation (we have no inference at this layer
|
||||
yet, so it's a parse-only pass-through).
|
||||
- [ ] `import` declarations anywhere at the start of a module — currently
|
||||
- [x] `import` declarations anywhere at the start of a module — currently
|
||||
only the very-top-of-file form is recognised. Real test programs that
|
||||
mix prelude code with `import qualified Data.IORef` need this.
|
||||
- [ ] Multi-line top-level `where` blocks (`where { ... }` with explicit
|
||||
@@ -420,6 +420,18 @@ constraints (qualified types `[ClassName var] => type`).
|
||||
|
||||
_Newest first._
|
||||
|
||||
**2026-05-10** — Phase 17 second box: `import` declarations anywhere among
|
||||
top-level decls. `hk-collect-module-body` previously ran a fixed
|
||||
import-loop at the start, then a separate decl-loop; merged into a single
|
||||
`hk-body-step` dispatcher that routes `import` to the imports list and
|
||||
everything else to `hk-parse-decl`. Each call site (initial step + post-
|
||||
semicolon loop) now uses the dispatcher. Imports collected mid-stream
|
||||
still feed into `hk-bind-decls!` correctly because the eval side reads
|
||||
them via the imports list, not by AST position. tests/parse-extras.sx
|
||||
12 → 17 covering very-top, mid-stream, post-main, two-imports-different-
|
||||
positions, and unqualified mid-file. Regression: eval 66/0, exceptions
|
||||
14/0, typecheck 15/0, records 14/0, ioref 13/0, map 26/0, set 17/0.
|
||||
|
||||
**2026-05-08** — Phase 17 first box: expression type annotations `(x :: Int)`,
|
||||
`f (1 :: Int)`, `(\x -> x+1) :: Int -> Int`. Parser's `hk-parse-parens`
|
||||
gains a `::` arm after the first inner expression: consume `::`, parse a
|
||||
|
||||
Reference in New Issue
Block a user