Skip to content

Commit abb5822

Browse files
authored
better error message for extension point (#5965)
* better error message for extension point * rename message for debugger extension * update CHANGELOG.md * fix typo
1 parent f03259a commit abb5822

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ These are only breaking changes for unformatted code.
6565
- Process `@set` annotation for field update as generating an uncurried function https://github.com/rescript-lang/rescript-compiler/pull/5846
6666
- Treat uncurried application of primitives like curried application, which produces better output https://github.com/rescript-lang/rescript-compiler/pull/5851
6767
- New internal representation for uncurried functions using built-in type `function$<fun_type, arity>` this avoids having to declare all the possible arities ahead of time https://github.com/rescript-lang/rescript-compiler/pull/5870
68+
- Better error message for extension point https://github.com/rescript-lang/rescript-compiler/pull/5965
6869

6970
# 10.1.1
7071

jscomp/frontend/ast_exp_handle_external.ml

+7-3
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,16 @@ let handle_debugger loc (payload : Ast_payload.t) =
6969
Ast_external_mk.local_external_apply loc ~pval_prim:[ "#debugger" ]
7070
~pval_type:(Typ.arrow Nolabel (Typ.any ()) (Ast_literal.type_unit ()))
7171
[ Ast_literal.val_unit ~loc () ]
72-
| _ -> Location.raise_errorf ~loc "bs.debugger does not accept payload"
72+
| _ -> Location.raise_errorf ~loc "%%debugger extension doesn't accept arguments"
7373

7474
let handle_raw ~kind loc payload =
7575
let is_function = ref false in
7676
match Ast_payload.raw_as_string_exp_exn ~kind ~is_function payload with
77-
| None -> Location.raise_errorf ~loc "bs.raw can only be applied to a string"
77+
| None ->
78+
(match kind with
79+
| Raw_re -> Location.raise_errorf ~loc "%%re extension can only be applied to a string"
80+
| Raw_exp -> Location.raise_errorf ~loc "%%raw extension can only be applied to a string"
81+
| Raw_program -> Location.raise_errorf ~loc "%%%%raw extension can only be applied to a string")
7882
| Some exp ->
7983
{
8084
exp with
@@ -99,4 +103,4 @@ let handle_raw_structure loc payload =
99103
~pval_type:(Typ.arrow Nolabel (Typ.any ()) (Typ.any ()))
100104
[ exp ];
101105
}
102-
| None -> Location.raise_errorf ~loc "bs.raw can only be applied to a string"
106+
| None -> Location.raise_errorf ~loc "%%%%raw extension can only be applied to a string"

0 commit comments

Comments
 (0)