Skip to content

Fix parser round-30 findings (alias args, error headers, flatten, generics) - #447

Open
owjs3901 wants to merge 1 commit into
mainfrom
fix/parser-round30
Open

owjs3901 wants to merge 1 commit into
mainfrom
fix/parser-round30

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

Round-30 parser fixes (crates/vespera_macro/src/parser/**), each verified against the code before fixing:

  • Return-type aliases: a bare-identifier const argument (Page<LIMIT, User> for type Page<const MAX: usize, T>) pairs with its const parameter, so the alias expands.
  • Error responses: a HeaderMap the error sets documents headers on its status, like the success side. Four error-header snapshots updated ("headers": {} only).
  • Flatten: the module doc now states that an opaque member keeping the object open drops the flattened map's value schema (JSON Schema cannot see the member's keys). Nothing is rejected.
  • Generic instances: a const argument of a nested type is part of the component name (Tree<Buf<u8, 4>> vs Tree<Buf<u8, 8>>).
  • Inlining: const-only definitions (Matrix<3>) inline with their length; const parameters named in value_type / into / from / try_from attributes are pinned by the instantiation.
  • value_type vs any: value_type wins over #[schema(any)] on the same field, matching the wire_override module doc. SchemaConstraints::any_decides is the single check used by every any-suppression site.
  • Tests and docs: vacuous contains('B') assertion now checks `Query<B>`; misleading serde_attrs test names and comments fixed.

Every behaviour change has a test that fails without it.

Verification

  • cargo test -p vespera_macro (5894 lib tests, trybuild, doc-tests): pass.
  • cargo test -p vespera: pass.
  • cargo clippy -p vespera_macro --all-targets -- -D warnings: clean. cargo fmt --check: clean.
  • All touched files stay under 1000 lines (conversion.rs is 986).

Not changed

  • The schema_assertions.rs leaf-type assertion still skips on any even when a value_type is present. That file is outside the parser scope; the skip is only a compile-time check, not an emitted schema.

🤖 Generated with Claude Code

…erics)

Return-type aliases:
- A const argument written as a bare identifier (Page<LIMIT, User> for
  type Page<const MAX: usize, T>) pairs with its const parameter and no
  longer counts as a type argument, so the alias still expands.

Responses:
- An error response documents the HeaderMap headers the error sets (bare
  or in the tuple) on its status, as the success side does. Snapshots for
  the error-header cases now show "headers": {}.

Flatten:
- The module doc states the limit: with an opaque member that keeps the
  object open, the flattened map's value schema is not emitted (JSON
  Schema additionalProperties cannot see the member's keys). Nothing is
  rejected.
- Test names and comments in serde_attrs (tag/content malformed values,
  default substring) describe what they test.

Generic instances and inlining:
- A const argument of a nested type is part of its component name
  (Tree<Buf<u8, 4>> and Tree<Buf<u8, 8>> no longer share Tree_Buf_u8).
- A const-only definition (Matrix<3>) inlines with its length.
- A const parameter named in value_type / into / from / try_from is
  pinned by the instantiation like one named in a field type.
- value_type wins over #[schema(any)] on the same field, as the
  wire_override module doc says; SchemaConstraints::any_decides is the
  one check every any-suppression site uses.

Tests: every behaviour change has a test that fails without it (alias
const pairing rstest cases, error header snapshots, nested const
injectivity and recursive component tests, const-only inline, value_type
attribute length, value_type over any). The vacuous contains('B') in
aliased_non_schema_type_import_is_flagged now asserts `Query<B>`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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