Debian Codegraph @

test-suite/output/bug_7443.v

raw
1 Inductive type := nat | bool.
2 Definition denote (t : type)
3 := match t with
4 | nat => Datatypes.nat
5 | bool => Datatypes.bool
6 end.
7 Ltac reify t :=
8 lazymatch eval cbv beta in t with
9 | Datatypes.nat => nat
10 | Datatypes.bool => bool
11 end.
12 Abbreviation reify t := (ltac:(let rt := reify t in exact rt)) (only parsing).
13 Abbreviation reify_type_of e := (reify ((fun t (_ : t) => t) _ e)) (only parsing).
14 Axiom Literal : forall {t}, denote t -> Type.
15 Declare Scope foo_scope.
16 Delimit Scope foo_scope with foo.
17 Open Scope foo_scope.
18 Section A.
19 Notation "[ x ]" := (Literal (t:=reify_type_of x) x) (only parsing) : foo_scope.
20 Check [1]. (* Literal 1 : Type *) (* as expected *)
21 Notation "[ x ]" := (Literal x) : foo_scope.
22 Check @Literal nat 1. (* Incorred: gives Literal 1 : Type when it should give [1]. Fixed by #12950 *)
23 Notation "[ x ]" := (Literal (t:=reify_type_of x) x) (only parsing) : foo_scope.
24 Check [1]. (* Incorrect: gives Literal 1 : Type when it should give [1]. This is disputable:
25 #12950 considers that giving an only parsing a previous both-parsing-and-printing notation *)
26 End A.
27 Section B.
28 Notation "[ x ]" := (Literal x) : foo_scope.
29 Check @Literal nat 1. (* [1] : Type *)
30 Fail Check [1]. (* As expected: The command has indeed failed with message:
31 The term "1" has type "Datatypes.nat" while it is expected to have type
32 "denote ?t". *)
33 Notation "[ x ]" := (Literal (t:=reify_type_of x) x) (only parsing) : foo_scope.
34 Check [1]. (* Should succeed, but instead fails with: Error:
35 The term "1" has type "Datatypes.nat" while it is expected to have type
36 "denote ?t". Fixed by #12950, but previous declaration is cancelled by #12950. *)
37 End B.