From aa5daf8e63bb018a05b5fbfb2b8a3e35a71b63b2 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 3 Sep 2024 11:37:12 +0200 Subject: [PATCH 1/2] Remove attribute "internal.arity" --- jscomp/frontend/ast_attributes.ml | 10 ---- jscomp/frontend/ast_attributes.mli | 2 - jscomp/frontend/ast_derive_abstract.ml | 2 +- jscomp/ml/typedecl.ml | 16 +------ .../expected/nonRecTypes.res.txt | 46 ++++++++----------- .../parsing/infiniteLoops/nonRecTypes.res | 6 --- 6 files changed, 22 insertions(+), 60 deletions(-) diff --git a/jscomp/frontend/ast_attributes.ml b/jscomp/frontend/ast_attributes.ml index 48d50b6503..774da2c3f9 100644 --- a/jscomp/frontend/ast_attributes.ml +++ b/jscomp/frontend/ast_attributes.ml @@ -275,16 +275,6 @@ let get : attr = ({txt = "get"; loc = locg}, Ast_payload.empty) let get_index : attr = ({txt = "get_index"; loc = locg}, Ast_payload.empty) -let bs_get_arity : attr = - ( {txt = "internal.arity"; loc = locg}, - PStr - [ - { - pstr_desc = Pstr_eval (Ast_compatible.const_exp_int ~loc:locg 1, []); - pstr_loc = locg; - }; - ] ) - let set : attr = ({txt = "set"; loc = locg}, Ast_payload.empty) let internal_expansive : attr = diff --git a/jscomp/frontend/ast_attributes.mli b/jscomp/frontend/ast_attributes.mli index b38ccc205f..91b151a30d 100644 --- a/jscomp/frontend/ast_attributes.mli +++ b/jscomp/frontend/ast_attributes.mli @@ -58,8 +58,6 @@ val get : attr val get_index : attr -val bs_get_arity : attr - val set : attr val bs_return_undefined : attr diff --git a/jscomp/frontend/ast_derive_abstract.ml b/jscomp/frontend/ast_derive_abstract.ml index c0400eeb9b..b4bcf122a2 100644 --- a/jscomp/frontend/ast_derive_abstract.ml +++ b/jscomp/frontend/ast_derive_abstract.ml @@ -57,7 +57,7 @@ let is_abstract (xs : Ast_payload.action list) = let get_optional_attrs = [Ast_attributes.get; Ast_attributes.bs_return_undefined] -let get_attrs = [Ast_attributes.bs_get_arity] +let get_attrs = [] let set_attrs = [Ast_attributes.set] diff --git a/jscomp/ml/typedecl.ml b/jscomp/ml/typedecl.ml index 2dcbb224cf..bddd81d685 100644 --- a/jscomp/ml/typedecl.ml +++ b/jscomp/ml/typedecl.ml @@ -1730,21 +1730,7 @@ let transl_value_decl env loc valdecl = | [] -> raise (Error(valdecl.pval_loc, Val_in_structure)) | _ -> - let arity, from_constructor = - let rec scan_attributes (attrs : Parsetree.attributes) = - match attrs with - | ({txt = "internal.arity";_}, (* This is likely not needed in uncurried mode *) - PStr [ {pstr_desc = Pstr_eval - ( - ({pexp_desc = Pexp_constant (Pconst_integer (i,_))} : - Parsetree.expression) ,_)}]) :: _ -> - Some (int_of_string i) - | _ :: rest -> scan_attributes rest - | [] -> None - in - match scan_attributes valdecl.pval_attributes with - | None -> parse_arity env valdecl.pval_type ty - | Some x -> x, false + let arity, from_constructor = parse_arity env valdecl.pval_type ty in let prim = Primitive.parse_declaration valdecl ~arity ~from_constructor in let prim_native_name = prim.prim_native_name in diff --git a/jscomp/syntax/tests/parsing/infiniteLoops/expected/nonRecTypes.res.txt b/jscomp/syntax/tests/parsing/infiniteLoops/expected/nonRecTypes.res.txt index b8cab408c9..12823f3964 100644 --- a/jscomp/syntax/tests/parsing/infiniteLoops/expected/nonRecTypes.res.txt +++ b/jscomp/syntax/tests/parsing/infiniteLoops/expected/nonRecTypes.res.txt @@ -25,39 +25,39 @@ Syntax error! - tests/parsing/infiniteLoops/nonRecTypes.res:67:26-68:3 + tests/parsing/infiniteLoops/nonRecTypes.res:61:26-62:3 - 65 │ }; - 66 │ let has = (rbt, value) => _findNode(rbt, rootGet(rbt), value) !== None; - 67 │ let rec minNode = node => - 68 │ let findMin = rbt => - 69 │ let removeNode = (rbt, node) => { - 70 │ let nodeToRemove = + 59 │ }; + 60 │ let has = (rbt, value) => _findNode(rbt, rootGet(rbt), value) !== None; + 61 │ let rec minNode = node => + 62 │ let findMin = rbt => + 63 │ let removeNode = (rbt, node) => { + 64 │ let nodeToRemove = I'm not sure what to parse here when looking at "let". Syntax error! - tests/parsing/infiniteLoops/nonRecTypes.res:68:21-69:3 + tests/parsing/infiniteLoops/nonRecTypes.res:62:21-63:3 - 66 │ let has = (rbt, value) => _findNode(rbt, rootGet(rbt), value) !== None; - 67 │ let rec minNode = node => - 68 │ let findMin = rbt => - 69 │ let removeNode = (rbt, node) => { - 70 │ let nodeToRemove = - 71 │ switch (leftGet(node), rightGet(node)) { + 60 │ let has = (rbt, value) => _findNode(rbt, rootGet(rbt), value) !== None; + 61 │ let rec minNode = node => + 62 │ let findMin = rbt => + 63 │ let removeNode = (rbt, node) => { + 64 │ let nodeToRemove = + 65 │ switch (leftGet(node), rightGet(node)) { I'm not sure what to parse here when looking at "let". Syntax error! - tests/parsing/infiniteLoops/nonRecTypes.res:434:31-38 + tests/parsing/infiniteLoops/nonRecTypes.res:428:31-38 - 432 │ updateSum(Some(node), ~delta); - 433 │ }; - 434 │ type nonrec oldNewVisibleNodes('value) = { - 435 │ mutable old: array('value), - 436 │ mutable new_: array('value), + 426 │ updateSum(Some(node), ~delta); + 427 │ }; + 428 │ type nonrec oldNewVisibleNodes('value) = { + 429 │ mutable old: array('value), + 430 │ mutable new_: array('value), Type parameters require angle brackets: oldNewVisibleNodes<'value> @@ -93,10 +93,8 @@ include ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x15\0\0\0\t\0\0\0\x1a\0\0\0\x19\xb0\xa0\xa0A\x91@\xa0\xa0A\x04\x03@E\x97\xa0$size@|js} ;;[|(({js|use sizeGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] - ;;[|((1)[@internal.arity ])|] external size : ('value t -> int, [ `Has_arity1 ]) function$ = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$size@|js} - ;;[|((1)[@internal.arity ])|] external sizeGet : ('value t -> int, [ `Has_arity1 ]) function$ = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$size@|js} external rootSet : @@ -105,24 +103,20 @@ include ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x15\0\0\0\t\0\0\0\x1a\0\0\0\x19\xb0\xa0\xa0A\x91@\xa0\xa0A\x04\x03@E\x97\xa0$root@|js} ;;[|(({js|use rootGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] - ;;[|((1)[@internal.arity ])|] external root : ('value t -> 'value node option, [ `Has_arity1 ]) function$ = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$root@|js} - ;;[|((1)[@internal.arity ])|] external rootGet : ('value t -> 'value node option, [ `Has_arity1 ]) function$ = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$root@|js} ;;[|(({js|use compareGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] - ;;[|((1)[@internal.arity ])|] external compare : ('value t -> [ [%rescript.typehole ]] Js.Internal.fn, [ `Has_arity1 ]) function$ ;;(({js|Arity_2('value, 'value)], int) = "" "BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x13\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0'compare@"; - [@internal.arity 1] external compareGet: t('value) => Js.Internal.fn([ | |js}) [@res.template ]) diff --git a/jscomp/syntax/tests/parsing/infiniteLoops/nonRecTypes.res b/jscomp/syntax/tests/parsing/infiniteLoops/nonRecTypes.res index f05582cbc6..b2a8779a00 100644 --- a/jscomp/syntax/tests/parsing/infiniteLoops/nonRecTypes.res +++ b/jscomp/syntax/tests/parsing/infiniteLoops/nonRecTypes.res @@ -27,11 +27,9 @@ include { [@ocaml.deprecated "use sizeGet instead or use {abstract = light} explicitly" ] - [@internal.arity 1] external size: t('value) => int = "" "BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$size@"; - [@internal.arity 1] external sizeGet: t('value) => int = "" "BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$size@"; @@ -41,23 +39,19 @@ include { [@ocaml.deprecated "use rootGet instead or use {abstract = light} explicitly" ] - [@internal.arity 1] external root: t('value) => option(node('value)) = "" "BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$root@"; - [@internal.arity 1] external rootGet: t('value) => option(node('value)) = "" "BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$root@"; [@ocaml.deprecated "use compareGet instead or use {abstract = light} explicitly" ] - [@internal.arity 1] external compare: t('value) => Js.Internal.fn([ | `Arity_2('value, 'value)], int) = "" "BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x13\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0'compare@"; - [@internal.arity 1] external compareGet: t('value) => Js.Internal.fn([ | `Arity_2('value, 'value)], int) = "" From 2d85e3dc211fcb2aa94c72082e486d1ec0418074 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 3 Sep 2024 12:34:22 +0200 Subject: [PATCH 2/2] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a50b0d335..e59f582e68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - Add dev container. https://github.com/rescript-lang/rescript-compiler/pull/6962 - Convert more tests to the node test runner. https://github.com/rescript-lang/rescript-compiler/pull/6956 +- Remove attribute "internal.arity". https://github.com/rescript-lang/rescript-compiler/pull/7004 # 12.0.0-alpha.1