Skip to content

AST: Remove Pexp_new #7239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- AST cleanup: Prepare for ast async cleanup: Refactor code for "@res.async" payload handling and clean up handling of type and term parameters, so that now each `=>` in a function definition corresponds to a function. https://github.com/rescript-lang/rescript/pull/7223
- AST: always put type parameters first in function definitions. https://github.com/rescript-lang/rescript/pull/7233
- AST cleanup: Remove `@res.async` attribute from the internal representation, and add a flag to untyped and typed ASTs instead. https://github.com/rescript-lang/rescript/pull/7234
- AST cleanup: Remove `expression_desc.Pexp_new` from the untyped typed AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239

# 12.0.0-alpha.7

Expand Down
1 change: 0 additions & 1 deletion analysis/src/Utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ let identifyPexp pexp =
| Pexp_constraint _ -> "Pexp_constraint"
| Pexp_coerce _ -> "Pexp_coerce"
| Pexp_send _ -> "Pexp_send"
| Pexp_new _ -> "Pexp_new"
| Pexp_setinstvar _ -> "Pexp_setinstvar"
| Pexp_override _ -> "Pexp_override"
| Pexp_letmodule _ -> "Pexp_letmodule"
Expand Down
2 changes: 0 additions & 2 deletions compiler/frontend/bs_ast_invariant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ let emit_external_warnings : iterator =
(fun self ({pexp_loc = loc} as a) ->
match a.pexp_desc with
| Pexp_constant const -> check_constant loc const
| Pexp_new _ ->
Location.raise_errorf ~loc "OCaml style objects are not supported"
| Pexp_variant (s, None) when Ext_string.is_valid_hash_number s -> (
try ignore (Ext_string.hash_number_as_i32_exn s : int32)
with _ ->
Expand Down
1 change: 0 additions & 1 deletion compiler/frontend/bs_ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ module E = struct
| Pexp_constraint (e, t) ->
constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t)
| Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s)
| Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid)
| Pexp_setinstvar (s, e) ->
setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e)
| Pexp_override sel ->
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/ast_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ module Exp = struct
let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_constraint (a, b))
let coerce ?loc ?attrs a c = mk ?loc ?attrs (Pexp_coerce (a, (), c))
let send ?loc ?attrs a b = mk ?loc ?attrs (Pexp_send (a, b))
let new_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_new a)
let setinstvar ?loc ?attrs a b = mk ?loc ?attrs (Pexp_setinstvar (a, b))
let override ?loc ?attrs a = mk ?loc ?attrs (Pexp_override a)
let letmodule ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_letmodule (a, b, c))
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/ast_helper.mli
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ module Exp : sig
val constraint_ :
?loc:loc -> ?attrs:attrs -> expression -> core_type -> expression
val send : ?loc:loc -> ?attrs:attrs -> expression -> str -> expression
val new_ : ?loc:loc -> ?attrs:attrs -> lid -> expression
val setinstvar : ?loc:loc -> ?attrs:attrs -> str -> expression -> expression
val override :
?loc:loc -> ?attrs:attrs -> (str * expression) list -> expression
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/ast_iterator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ module E = struct
sub.expr sub e;
sub.typ sub t
| Pexp_send (e, _s) -> sub.expr sub e
| Pexp_new lid -> iter_loc sub lid
| Pexp_setinstvar (s, e) ->
iter_loc sub s;
sub.expr sub e
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ module E = struct
| Pexp_constraint (e, t) ->
constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t)
| Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s)
| Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid)
| Pexp_setinstvar (s, e) ->
setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e)
| Pexp_override sel ->
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/ast_mapper_from0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ module E = struct
| Pexp_constraint (e, t) ->
constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t)
| Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s)
| Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid)
| Pexp_new _ -> failwith "Pexp_new is no longer present in ReScript"
| Pexp_setinstvar (s, e) ->
setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e)
| Pexp_override sel ->
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/ast_mapper_to0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ module E = struct
| Pexp_constraint (e, t) ->
constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t)
| Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s)
| Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid)
| Pexp_setinstvar (s, e) ->
setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e)
| Pexp_override sel ->
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/depend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ let rec add_expr bv exp =
add_expr bv e1;
add_type bv ty2
| Pexp_send (e, _m) -> add_expr bv e
| Pexp_new li -> add bv li
| Pexp_setinstvar (_v, e) -> add_expr bv e
| Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel
| Pexp_letmodule (id, m, e) ->
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/parsetree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ and expression_desc =
(* (E :> T) (None, T)
*)
| Pexp_send of expression * label loc (* E # m *)
| Pexp_new of Longident.t loc (* new M.c *)
| Pexp_setinstvar of label loc * expression (* x <- 2 *)
| Pexp_override of (label loc * expression) list
(* {< x1 = E1; ...; Xn = En >} *)
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/pprintast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@ and expression ctxt f x =
in
let lst = sequence_helper [] x in
pp f "@[<hv>%a@]" (list (expression (under_semi ctxt)) ~sep:";@;") lst
| Pexp_new li -> pp f "@[<hov2>new@ %a@]" longident_loc li
| Pexp_setinstvar (s, e) ->
pp f "@[<hov2>%s@ <-@ %a@]" s.txt (expression ctxt) e
| Pexp_override l ->
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/printast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ and expression i ppf x =
| Pexp_send (e, s) ->
line i ppf "Pexp_send \"%s\"\n" s.txt;
expression i ppf e
| Pexp_new li -> line i ppf "Pexp_new %a\n" fmt_longident_loc li
| Pexp_setinstvar (s, e) ->
line i ppf "Pexp_setinstvar %a\n" fmt_string_loc s;
expression i ppf e
Expand Down
4 changes: 2 additions & 2 deletions compiler/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ let iter_expression f e =
f e;
match e.pexp_desc with
| Pexp_extension _ (* we don't iterate under extension point *)
| Pexp_ident _ | Pexp_new _ | Pexp_constant _ ->
| Pexp_ident _ | Pexp_constant _ ->
()
| Pexp_fun {default = eo; rhs = e} ->
may expr eo;
Expand Down Expand Up @@ -3034,7 +3034,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp
(Error
(e.pexp_loc, env, Undefined_method (obj.exp_type, met, valid_methods)))
)
| Pexp_new _ | Pexp_setinstvar _ | Pexp_override _ -> assert false
| Pexp_setinstvar _ | Pexp_override _ -> assert false
| Pexp_letmodule (name, smodl, sbody) ->
let ty = newvar () in
(* remember original level *)
Expand Down
1 change: 0 additions & 1 deletion compiler/syntax/src/res_ast_debugger.ml
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ module SexpAst = struct
| Pexp_coerce (expr, (), typexpr) ->
Sexp.list [Sexp.atom "Pexp_coerce"; expression expr; core_type typexpr]
| Pexp_send _ -> Sexp.list [Sexp.atom "Pexp_send"]
| Pexp_new _ -> Sexp.list [Sexp.atom "Pexp_new"]
| Pexp_setinstvar _ -> Sexp.list [Sexp.atom "Pexp_setinstvar"]
| Pexp_override _ -> Sexp.list [Sexp.atom "Pexp_override"]
| Pexp_letmodule (mod_name, mod_expr, expr) ->
Expand Down
1 change: 0 additions & 1 deletion compiler/syntax/src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,6 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl =
Doc.concat [Doc.text "\""; member_doc; Doc.text "\""]
in
Doc.group (Doc.concat [parent_doc; Doc.lbracket; member; Doc.rbracket])
| Pexp_new _ -> Doc.text "Pexp_new not implemented in printer"
| Pexp_setinstvar _ -> Doc.text "Pexp_setinstvar not implemented in printer"
| Pexp_override _ -> Doc.text "Pexp_override not implemented in printer"
| Pexp_poly _ -> Doc.text "Pexp_poly not implemented in printer"
Expand Down
Loading