Skip to content

Commit

Permalink
Add mapping and iterating to new location added to parsetree (fully r…
Browse files Browse the repository at this point in the history
…eviewed)

(cherry picked from commit 6232a43)
  • Loading branch information
ncik-roberts authored and mshinwell committed Aug 28, 2024
1 parent 294e7a8 commit 55a8152
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion ocaml/parsing/ast_iterator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ module T = struct
| Ltyp_poly { bound_vars; inner_type } ->
List.iter (bound_var sub) bound_vars;
sub.typ sub inner_type
| Ltyp_alias { aliased_type; name = _; jkind } ->
| Ltyp_alias { aliased_type; name; jkind } ->
sub.typ sub aliased_type;
iter_opt (iter_loc sub) name;
iter_loc_txt sub sub.jkind_annotation jkind

let iter_jst_labeled_tuple sub : LT.core_type -> _ = function
Expand Down
1 change: 1 addition & 0 deletions ocaml/parsing/ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module T = struct
Ltyp_poly { bound_vars; inner_type }
| Ltyp_alias { aliased_type; name; jkind } ->
let aliased_type = sub.typ sub aliased_type in
let name = map_opt (map_loc sub) name in
let jkind = map_loc_txt sub sub.jkind_annotation jkind in
Ltyp_alias { aliased_type; name; jkind }

Expand Down
10 changes: 5 additions & 5 deletions ocaml/testsuite/tests/typing-layouts/error_message_attr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ module type a = sig
val f : t -> (t as ('a : value)[@error_message "Custom message"])
end
[%%expect{|
Line 126, characters 22-24:
126 | val f : t -> (t as ('a : value)[@error_message "Custom message"])
^^
Error: This alias is bound to type "t" but is used as an instance of type
"('a : value)"
Line 3, characters 22-24:
3 | val f : t -> (t as ('a : value)[@error_message "Custom message"])
^^
Error: This alias is bound to type t but is used as an instance of type
('a : value)
The layout of t is float64
because of the definition of t at line 2, characters 2-18.
But the layout of t must be a sublayout of value
Expand Down

0 comments on commit 55a8152

Please sign in to comment.