Skip to content

Commit 96dee17

Browse files
authored
error message: private extension without body (#6175)
1 parent c6c8962 commit 96dee17

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- Fixed subtype checking for record types with "@as" attributes: The subtype relationship now takes into account the compatibility of "@as" attributes between corresponding fields, ensuring correctness in runtime representation.
2727
https://github.com/rescript-lang/rescript-compiler/issues/6158
2828
- Emit directive above header comment. https://github.com/rescript-lang/rescript-compiler/pull/6172
29+
- Add error message to private extension. https://github.com/rescript-lang/rescript-compiler/pull/6175
2930

3031
#### :nail_care: Polish
3132

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/private_without_body.res:1:1-9
4+
5+
1 │ %%private
6+
2 │ let a = 2
7+
3 │
8+
9+
%%private extension expects a definition as its argument. Example: %%private(let a = "Hello")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
%%private
2+
let a = 2

jscomp/frontend/bs_builtin_ppx.ml

+3
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ let rec structure_mapper (self : mapper) (stru : Ast_structure.t) =
474474
:: next -> (
475475
match payload with
476476
| PStr work ->
477+
if List.length work = 0 then
478+
Location.raise_errorf ~loc
479+
{|%%%%private extension expects a definition as its argument. Example: %%%%private(let a = "Hello")|};
477480
aux
478481
(Ext_list.rev_map_append work acc (fun x ->
479482
self.structure_item self x))

0 commit comments

Comments
 (0)