Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ typing/cmt2annot.cmi : \
parsing/location.cmi \
file_formats/cmt_format.cmi
typing/ctype.cmo : \
utils/warnings.cmi \
typing/types.cmi \
typing/type_immediacy.cmi \
typing/subst.cmi \
Expand All @@ -638,7 +637,6 @@ typing/ctype.cmo : \
parsing/asttypes.cmi \
typing/ctype.cmi
typing/ctype.cmx : \
utils/warnings.cmx \
typing/types.cmx \
typing/type_immediacy.cmx \
typing/subst.cmx \
Expand Down
11 changes: 1 addition & 10 deletions testsuite/tests/macros/gadts.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,29 @@ macro m : type a. (a, int) Type.eq expr -> a -> unit expr =
;;

[%%expect{|
File "_none_", line 1:
Warning 75 [maco-dev]: maco: avoided gadt constraint at level 0

Line 3, characters 47-48:
3 | << match $p with Type.Equal -> $(let _ = 1 + x in << () >>) >>
^
Error: The value "x" has type "a" but an expression was expected of type "int"
|}]

(* TODO: we don't need a warning here *)
macro m : type a. (a, int) Type.eq expr -> unit expr =
fun p ->
<< match $p with Type.Equal -> () >>
;;

[%%expect{|
File "_none_", line 1:
Warning 75 [maco-dev]: maco: avoided gadt constraint at level 0

macro m : ('a, int) Type.eq expr -> unit expr = <fun>
|}]


(* TODO: we should eventually allow this *)
macro m : type a. (a, int) Type.eq expr -> a expr -> int expr =
fun p x ->
<< match $p with Type.Equal -> $x >>
;;

[%%expect{|
File "_none_", line 1:
Warning 75 [maco-dev]: maco: avoided gadt constraint at level 0

Line 3, characters 34-35:
3 | << match $p with Type.Equal -> $x >>
^
Expand Down
9 changes: 3 additions & 6 deletions typing/ctype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2584,14 +2584,11 @@ let add_gadt_equation uenv source destination =
expressive)? as that lets us do anything inside an (unquoted) macro body *)

let env = get_env uenv in

let staging_level = Env.get_env_level env in

let staging_mode = Env.get_env_mode env in

if (* staging_level <> 0 ||*) staging_mode <> M_C then
Location.prerr_warning Location.none (Warnings.Maco_dev
("avoided gadt constraint at level "^(string_of_int staging_level)))
else begin
if (* staging_level <> 0 ||*) staging_mode = M_C then
begin
Copy link
Member

Choose a reason for hiding this comment

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

I think this removes too much: we don't need the warning, but we probably do still need the check staging_mode <> M_C that guards the else branch.

if has_free_univars env destination then
occur_univar ~inj_only:true env destination
else if local_non_recursive_abbrev uenv source destination then begin
Expand Down
Loading