Skip to content

Address code review: Int/Nat subtyping, CLI validation, mismatch docs#34

Merged
aallan merged 1 commit into
mainfrom
housekeeping-review-followups
Feb 24, 2026
Merged

Address code review: Int/Nat subtyping, CLI validation, mismatch docs#34
aallan merged 1 commit into
mainfrom
housekeeping-review-followups

Conversation

@aallan

@aallan aallan commented Feb 24, 2026

Copy link
Copy Markdown
Owner

Summary

Housekeeping PR addressing substantive points from a code review before starting C6.

1. Int/Nat bidirectional subtyping (+3 verifier tests, +spec note)

The type checker permits Int <: Nat (rule 3b in is_subtype()) but this was:

  • Untested in the verifier — no test showing a negative Int returned as Nat gets caught
  • Undocumented in the specspec/02-types.md listed the complete subtyping relation without mentioning Int→Nat

Fix: Added 3 verifier tests (negative caught, positive passes, conditional paths) and an implementation note in the spec's subtyping section.

2. CLI argument validation (+3 CLI tests, +bug fix)

vera run file.vera -- abc caused a raw Python ValueError traceback instead of a clean error message. The int(a) parsing in main() had no error handling.

Fix: Added try/except with clean error message (Invalid integer argument(s): abc), JSON mode support, and 3 subprocess tests.

3. Spec/parser mismatch documentation

The 30 MISMATCH items in check_spec_examples.py (spec uses @T in data/effect declarations, parser expects bare T) were tracked in the script but not documented anywhere user-facing.

Fix: Added a paragraph to vera/README.md Current Limitations explaining the design distinction (value-level vs type-level binding notation) and that reconciliation is tracked.

4. Test count updates

508 → 514 tests across all documentation files.

Test plan

  • 514 tests pass
  • mypy clean (14 source files)
  • All 14 examples pass check + verify
  • All spec code blocks parse
  • Pre-commit hooks pass

…docs

Add verifier tests for Int→Nat subtyping enforcement (3 tests):
- test_int_to_nat_negative_caught: returning -1 as Nat fails verification
- test_int_to_nat_positive_ok: non-negative Int passes as Nat
- test_int_to_nat_conditional: conditional with all-positive paths passes

Add CLI argument validation (3 tests + fix):
- Malformed integer args after -- now produce clean error instead of
  Python traceback (e.g. "vera run f.vera -- abc" → "Invalid integer")
- JSON mode returns structured error diagnostic
- Added _is_int_str() helper, try/except around int() parsing in main()

Document spec/parser @t notation mismatch in vera/README.md:
- 30 spec blocks use @t in data/effect declarations; parser expects bare T
- Explains the design distinction (value-level vs type-level bindings)
- Notes reconciliation is tracked in scripts/check_spec_examples.py

Add implementation note to spec/02-types.md explaining that Int <: Nat
is permitted by the type checker with the verifier enforcing >= 0 via Z3.

Update test counts: 508 → 514 tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aallan aallan merged commit 2b0056d into main Feb 24, 2026
10 checks passed
@aallan aallan deleted the housekeeping-review-followups branch February 24, 2026 12:26
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