File tree Expand file tree Collapse file tree 5 files changed +29
-2
lines changed
tests/build_tests/super_errors Expand file tree Collapse file tree 5 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 23
23
#### :bug : Bug fix
24
24
25
25
- Fix code generation for emojis in polyvars and labels. https://github.com/rescript-lang/rescript/pull/7853
26
+ - Fix crash with ` @get ` on external of type ` unit => 'a ` . https://github.com/rescript-lang/rescript/pull/7866
26
27
27
28
#### :memo : Documentation
28
29
Original file line number Diff line number Diff line change @@ -421,7 +421,11 @@ let translate_ffi ?(transformed_jsx = false) (cxt : Lam_compile_context.t)
421
421
| [obj] ->
422
422
let obj = translate_scoped_access scopes obj in
423
423
E. dot obj name
424
- | _ -> assert false
424
+ | _ ->
425
+ (* This should have been caught in the frontend validation. *)
426
+ invalid_arg
427
+ " Internal compiler error: @get external called with wrong number of \
428
+ arguments. Expected exactly one object argument."
425
429
(* Note these assertion happens in call site *) )
426
430
| Js_set {js_set_name = name ; js_set_scopes = scopes } -> (
427
431
(* assert (js_splice = false) ; *)
Original file line number Diff line number Diff line change @@ -899,7 +899,12 @@ let external_desc_of_non_obj (loc : Location.t) (st : external_desc)
899
899
tagged_template = _;
900
900
} ->
901
901
if arg_type_specs_length = 1 then
902
- Js_get {js_get_name = name; js_get_scopes = scopes}
902
+ (* Check if the first argument is unit, which is invalid for @get *)
903
+ match arg_type_specs with
904
+ | [{arg_type = Extern_unit }] ->
905
+ Location. raise_errorf ~loc
906
+ " Ill defined attribute %@get (unit argument is not allowed)"
907
+ | _ -> Js_get {js_get_name = name; js_get_scopes = scopes}
903
908
else
904
909
Location. raise_errorf ~loc
905
910
" Ill defined attribute %@get (only one argument)"
Original file line number Diff line number Diff line change
1
+
2
+ [1;31mWe've found a bug for you![0m
3
+ [36m/.../fixtures/get_unit_arg.res[0m:[2m2:1-3:36[0m
4
+
5
+ 1 [2m│[0m // Test case for issue #7676 - @get external with unit => 'a should give
6
+ [2m│[0m proper error
7
+ [1;31m2[0m [2m│[0m [1;31m@get[0m
8
+ [1;31m3[0m [2m│[0m [1;31mexternal foo: unit => string = "foo"[0m
9
+ 4 [2m│[0m
10
+ 5 [2m│[0m let x = foo()
11
+
12
+ Ill defined attribute @get (unit argument is not allowed)
Original file line number Diff line number Diff line change
1
+ // Test case for issue #7676 - @get external with unit => 'a should give proper error
2
+ @get
3
+ external foo : unit => string = "foo"
4
+
5
+ let x = foo ()
You can’t perform that action at this time.
0 commit comments