Skip to content

Aligning implementation/specification error codes - phase 4 - #1993

Open
Roman-Manevich wants to merge 9 commits into
masterfrom
asl-error-codes-phase-4
Open

Aligning implementation/specification error codes - phase 4#1993
Roman-Manevich wants to merge 9 commits into
masterfrom
asl-error-codes-phase-4

Conversation

@Roman-Manevich

Copy link
Copy Markdown
Collaborator

Classify unsupported parameter expressions

Expressions that cannot define subprogram parameters now report TE_BSPD through BadParameterExpr, matching params_of_expr in asl.spec.

Classify invalid collection field types

Non-bitvector collection fields now report TE_UT through check_structure_bits, matching the per-field check_structure_label checks in asl.spec.

Classify unsupported parameter types

Types not permitted as subprogram argument or return types now report TE_BSPD through BadParameterType; asl.spec and a documented regression now cover pending-constrained integers, and the obsolete UnsupportedTy diagnostic is removed.

Classify out-of-bounds indices

Out-of-bounds native vector accesses now report DE_BI, or TE_SEF during static evaluation, through BadIndex instead of the uncoded MismatchType diagnostic.

Classify arbitrary negative-length arrays

Parameterized arrays whose length evaluates negatively now report DE_AET through ArbitraryEmptyType, matching EArbitrary in asl.spec.

Classify static evaluation failures

Static evaluation that does not produce a literal now reports TE_SEF through StaticEvaluationFailure, matching static_eval in asl.spec.

Classify implementation integer overflow

Integers exceeding OCaml int limits now report a structured internal ImplementationIntegerOverflow diagnostic instead of the uncoded UnsupportedExpr.

@Roman-Manevich
Roman-Manevich changed the base branch from master to asl-error-codes-phase-3 September 5, 2026 22:53
@Roman-Manevich
Roman-Manevich force-pushed the asl-error-codes-phase-4 branch 3 times, most recently from 3ec2709 to 6ac171a Compare September 5, 2026 23:43
@Roman-Manevich
Roman-Manevich requested review from HadrienRenaud and hrutvik and removed request for HadrienRenaud September 6, 2026 15:31
@Roman-Manevich
Roman-Manevich marked this pull request as ready for review September 6, 2026 15:32
Comment thread asllib/error.ml
| BadField of string * ty
| MissingField of string list * ty
| BadSlices of error_handling_time * slice list * int
| BadIndex of error_handling_time * int * int

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth a record I think

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer records, but why this specific one and not all other constructors with multiple fields?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see at least two reasons:

  • A record clearly differentiates between the two arguments with the same int type.
  • This constructor was added in this PR - we can make it better quality than other constructors without being inconsistent.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I want to prevent this type of error: you have switched your arguments around and the type system does not catch it.
For example, it is not obvious that this code is wrong, and it will be accepted by the ocaml type-checker:

  fatal ~loc (Error.BadIndex (Static, actual, expected))

By naming things we can make this class of errors far more difficult to happen:

  fatal ~loc (Error.BadIndex { error_handling_time = Static; actual; expected })

This is the same reasoning for naming arguments to functions. The only exception to this is when it things are left-to-right ordered, e.g. plus x y makes as much sense as plus ~lhs:x ~rhs:y.

Comment thread asllib/tests/regressions.t/run.t Outdated
File static-evaluation-non-literal.asl, line 5, characters 13 to 24:
constant C = R { x = 1 };
^^^^^^^^^^^
ASL Type error (TE_SEF): Static evaluation of expression R { x = 1 } failed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I had forgotten we had this limitation. Could we put it on a ticket please?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you want the ticket to say.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that ASLRef does not support initialising constants with compound expressions when it is not forbidden by type-checking?

@Roman-Manevich
Roman-Manevich force-pushed the asl-error-codes-phase-4 branch from 6ac171a to 6589fe9 Compare September 7, 2026 09:12
Comment thread asllib/error.ml Outdated

@hrutvik hrutvik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure @HadrienRenaud has approved before merging.

[1]

Implementation errors:
$ aslref --gnu-errors implementation-integer-overflow.asl

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why --gnu-errors here?

Base automatically changed from asl-error-codes-phase-3 to master September 8, 2026 17:45
@Roman-Manevich
Roman-Manevich force-pushed the asl-error-codes-phase-4 branch from bd22e37 to 43d4191 Compare September 8, 2026 17:51
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.

3 participants