diff --git a/CHANGELOG.md b/CHANGELOG.md index 070c866edc..d778209539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - Fix formatting of trailing comments before `=` in let bindings. https://github.com/rescript-lang/rescript/pull/8444 - Fix analysis namespace parsing after the Yojson migration. https://github.com/rescript-lang/rescript/pull/8454 - Fix namespaced reference lookup in editor analysis. https://github.com/rescript-lang/rescript/pull/8455 +- Fix analysis segmentation fault for references after https://github.com/rescript-lang/rescript/pull/7887. https://github.com/rescript-lang/rescript/pull/8477 #### :memo: Documentation diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index 29207d0150..86bf4e7ba9 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -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) @@ -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 *)} diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index f772a0eb64..8149b9f4b1 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -119,14 +119,17 @@ 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 + (* Keep new expression constructors at the end. CMT files are marshalled by + runtime constructor tag, so inserting constructors before existing ones + breaks analysis when it reads CMTs produced by older compiler versions. *) + | 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 diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index 538405a769..049fafd8a8 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -220,14 +220,17 @@ 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 + (* Keep new expression constructors at the end. CMT files are marshalled by + runtime constructor tag, so inserting constructors before existing ones + breaks analysis when it reads CMTs produced by older compiler versions. *) + | 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