Skip to content
Draft
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
13 changes: 12 additions & 1 deletion compiler/ext/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ and ast_impl_magic_number = "Caml1999M022"

and ast_intf_magic_number = "Caml1999N022"

and cmt_magic_number = "Caml1999T022"
(* Current magic written to .cmt/.cmti files. Bump this whenever the marshalled
typedtree/CMT shape changes. *)
and cmt_magic_number = "Caml1999T023"

(* Older CMT magics that are safe for current readers to consume. This lets
editor analysis support previous compiler versions while still writing a new
magic for artifacts generated by this compiler. Only add values whose
marshalled typedtree shape is compatible with the current one. *)
let supported_cmt_magic_numbers = [cmt_magic_number; "Caml1999T022"]

let is_supported_cmt_magic_number magic_number =
List.exists (String.equal magic_number) supported_cmt_magic_numbers

let load_path = ref ([] : string list)
8 changes: 6 additions & 2 deletions compiler/ext/config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ val ast_intf_magic_number : string
(* Magic number for file holding an interface syntax tree *)
val ast_impl_magic_number : string

(* Magic number for file holding an implementation syntax tree *)
val cmt_magic_number : string
(* Magic number for compiled interface files *)
(* Magic number written to current compiled typedtree files *)

val supported_cmt_magic_numbers : string list
(* Current and compatible older compiled typedtree magic numbers *)

val is_supported_cmt_magic_number : string -> bool
4 changes: 2 additions & 2 deletions compiler/ml/cmt_format.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ let read filename =
try
let magic_number = read_magic_number ic in
let cmi, cmt =
if magic_number = Config.cmt_magic_number then
if Config.is_supported_cmt_magic_number magic_number then
None, Some (input_cmt ic)
else if magic_number = Config.cmi_magic_number then
let cmi = Cmi_format.input_cmi ic in
let cmt = try
let magic_number = read_magic_number ic in
if magic_number = Config.cmt_magic_number then
if Config.is_supported_cmt_magic_number magic_number then
let cmt = input_cmt ic in
Some cmt
else None
Expand Down
8 changes: 4 additions & 4 deletions compiler/ml/parsetree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ and expression_desc =
(* for i = E1 to E2 do E3 done (flag = Upto)
for i = E1 downto E2 do E3 done (flag = Downto)
*)
| Pexp_for_of of pattern * expression * expression
(* for pattern of array_expr do body_expr *)
| Pexp_for_await_of of pattern * expression * expression
(* for await pattern of iterable_expr do body_expr *)
| Pexp_constraint of expression * core_type (* (E : T) *)
| Pexp_coerce of expression * unit * core_type
(* (E :> T) (None, T)
Expand Down Expand Up @@ -322,6 +318,10 @@ and expression_desc =
(* . *)
| Pexp_await of expression
| Pexp_jsx_element of jsx_element
| Pexp_for_of of pattern * expression * expression
(* for pattern of array_expr do body_expr *)
| Pexp_for_await_of of pattern * expression * expression
(* for await pattern of iterable_expr do body_expr *)

(* an element of a record pattern or expression *)
and 'a record_element = {lid: Longident.t loc; x: 'a; opt: bool (* optional *)}
Expand Down
4 changes: 2 additions & 2 deletions compiler/ml/typedtree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ and expression_desc =
* expression
* direction_flag
* expression
| Texp_for_of of Ident.t * Parsetree.pattern * expression * expression
| Texp_for_await_of of Ident.t * Parsetree.pattern * expression * expression
| Texp_send of expression * meth * expression option
| Texp_letmodule of Ident.t * string loc * module_expr * expression
| Texp_letexception of extension_constructor * expression
| Texp_assert of expression
| Texp_pack of module_expr
| Texp_extension_constructor of Longident.t loc * Path.t
| Texp_for_of of Ident.t * Parsetree.pattern * expression * expression
| Texp_for_await_of of Ident.t * Parsetree.pattern * expression * expression

and meth = Tmeth_name of string

Expand Down
4 changes: 2 additions & 2 deletions compiler/ml/typedtree.mli
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ and expression_desc =
* expression
* direction_flag
* expression
| Texp_for_of of Ident.t * Parsetree.pattern * expression * expression
| Texp_for_await_of of Ident.t * Parsetree.pattern * expression * expression
| Texp_send of expression * meth * expression option
| Texp_letmodule of Ident.t * string loc * module_expr * expression
| Texp_letexception of extension_constructor * expression
| Texp_assert of expression
| Texp_pack of module_expr
| Texp_extension_constructor of Longident.t loc * Path.t
| Texp_for_of of Ident.t * Parsetree.pattern * expression * expression
| Texp_for_await_of of Ident.t * Parsetree.pattern * expression * expression

and meth = Tmeth_name of string

Expand Down
Loading