Skip to content

audit:storage checks the type table (#692) - #3390

Merged
ehartford merged 1 commit into
mainfrom
audit-type-table
Nov 17, 2026
Merged

ehartford merged 1 commit into
mainfrom
audit-type-table

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Part of #692 (the range checks; the context rule for sub-byte integer types is left, see below).

get_generic_inst_arg once read the argument vector of a type that is not a generic instance. What it returned depended on the type table's layout; under one layout it was a sub-byte integer, a literal was typed with it, and audit:all reported no violation. The accessors are kind-guarded since; this is the instrument for the class.

audit:storage (and so audit:all) now also checks:

  • the type table's columns are parallel;
  • every generic instance's argument vector lies inside type_extra and each argument is a type id (Analysis.analysis_generic_instance_violations, a function of the table's columns);
  • every entry of typed_expr_types is a type id.

Clean on the compiler's own source: with analyze src/main.w audit:storage → facts=1560278 violations=0 ok.

Test: test/internals/analysis_type_table_test.w hands the check tables with a stray argument, a vector that leaves the table and a negative start, and a clean one.

Not done, and why: "a sub-byte integer type only inside a bit-packed layout". A bitfield setter takes its field's type (D147), so a literal typed u3 is legitimate there; the rule needs the expression's context, not a range check.

Battery GREEN (6f4b99c).

…ctor lies in the table and names types, and every typed expression names a type (#692)
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