Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Rewatch: warnings for unsupported/unknown rescript.json fields. https://github.com/rescript-lang/rescript/pull/8031
- Fix missing `ignore` function in some Stdlib modules. https://github.com/rescript-lang/rescript/pull/8060
- Fix signature matching for externals when abstract alias hides function arity. https://github.com/rescript-lang/rescript/pull/8045
- Fix arity detection for arrows returning nested generics. https://github.com/rescript-lang/rescript/pull/8064

#### :memo: Documentation

Expand Down
4 changes: 3 additions & 1 deletion compiler/syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,10 @@ let is_es6_arrow_expression ~in_ternary p =
(match state.Parser.token with
(* arrived at `() :typ<` here *)
| LessThan ->
Scanner.set_diamond_mode state.scanner;
Parser.next state;
go_to_closing GreaterThan state
go_to_closing GreaterThan state;
Scanner.pop_mode state.scanner Diamond
| _ -> ());
match state.Parser.token with
(* arrived at `() :typ =>` or `() :typ<'a,'b> =>` here *)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@ let arr = (): array<nullable<int>> => []

let fn = f => f;
type f = int => unit;
let a = fn(_ => (): f);
let a = fn(_ => (): f);

let returnsArrayOption = (): option<array<string>> => Some(["foo"])
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ type nonrec u = unit
let un = (() : u)
type nonrec ('a, 'b) d = ('a * 'b)
let c [arity:1]() = ((1, 2) : ('a, 'b) d)
let arr () = ([||] : int nullable array)
let arr [arity:1]() = ([||] : int nullable array)
let fn [arity:1]f = f
type nonrec f = int -> unit (a:1)
let a = fn (fun [arity:1]_ -> () : f)
let a = fn (fun [arity:1]_ -> () : f)
let returnsArrayOption [arity:1]() =
(Some [|{js|foo|js}|] : string array option)
22 changes: 22 additions & 0 deletions tests/tests/src/nested_generic_return.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Generated by ReScript, PLEASE EDIT WITH CARE


function foo() {
return ["foo"];
}

let bar = ["foo"];

function nested() {
return 1;
}

let baz = 1;

export {
foo,
bar,
nested,
baz,
}
/* No side effect */
7 changes: 7 additions & 0 deletions tests/tests/src/nested_generic_return.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// https://github.com/rescript-lang/rescript/issues/8055

let foo = (): option<array<string>> => Some(["foo"])
let bar = foo()

let nested = (): option<option<int>> => Some(Some(1))
let baz = nested()
Loading