Skip to content

Improve behaviour regarding unsupported constructs#468

Open
n-osborne wants to merge 5 commits into
ocaml-gospel:mainfrom
n-osborne:unsupported
Open

Improve behaviour regarding unsupported constructs#468
n-osborne wants to merge 5 commits into
ocaml-gospel:mainfrom
n-osborne:unsupported

Conversation

@n-osborne

@n-osborne n-osborne commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

This patch proposes to improve how unsupported OCaml constructs are handled by the Gospel type-checker.

Fixes #467

The current behaviour is to fail with an assert false when we encounter an unsupported construct.
This is decided when parsing the OCaml attributes containing the Gospel annotation (with the AST traversal).

The proposed behaviour is to fail with an informative error message when an unsupported OCaml contruct is annotated with some Gospel specifications.
Unupported OCaml constructs that are not annotated are simply ignored.

The information carried by the error is the name of the construct and the location so that the incriminated line of code is displayed with the error message.

Caveat: test/Typechecking/unsupported/variant_as_argument.mli reads as follow:

type t = A | B

val f : t -> bool
(* {gospel_expected|
[1] File "variant_as_argument.mli", line 3, characters 8-9:
    3 | val f : t -> bool
                ^
    Error: Unbound type constructor t
    
|gospel_expected} *)

What is happening is that the type declaration is ignored (unsupported but not specified), the type-checker later adds a header to the unspecified value definition and fail to find t in the typing environment.

But this is related to another problem, hence out of scope of this patch.

@n-osborne n-osborne marked this pull request as ready for review May 28, 2026 07:53
@n-osborne n-osborne force-pushed the unsupported branch 3 times, most recently from 5ba8c9b to 9dabbbc Compare May 29, 2026 15:19
@n-osborne n-osborne marked this pull request as draft May 29, 2026 15:20
n-osborne added 5 commits June 4, 2026 16:23
This commit makes Gospel type-checker stop failling when it encounters
an unsupported construct. The unsupported constructs are simply filtered
out of the untyped ast.
The `Uattr2spec.Unsupported` exception now carries two pieces of
information:

1. a description of the construct (polymorphic variant, object...)
2. the location
If an unsupported construct is specified, we raise an `Unsupported`
error as the spcifications don't make any sense.
If an unsupported construct appears in the module but is not annotated
with some Gospel specification, we simply ignore it.
@n-osborne n-osborne linked an issue Jun 4, 2026 that may be closed by this pull request
@n-osborne n-osborne marked this pull request as ready for review June 4, 2026 16:09
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.

Making type checker ignore unsupported constructs

1 participant