Skip to content

Commit 8b15094

Browse files
authored
Merge pull request #4911 from ELLIOTTCABLE/agnostic-deriving
Relax uninterpretable attributes (such as non-BuckleScript @@deriving payloads) from error to warn
2 parents 136c320 + f3a2811 commit 8b15094

File tree

6 files changed

+64
-13
lines changed

6 files changed

+64
-13
lines changed

jscomp/syntax/ast_derive_util.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ val notApplicable:
4949
string ->
5050
unit
5151

52-
val invalid_config : Parsetree.expression -> 'a
52+
val invalid_config : Parsetree.expression -> 'a

jscomp/syntax/ast_payload.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ type action =
130130
*)
131131

132132

133+
let unrecognizedConfigRecord loc text =
134+
Location.prerr_warning
135+
loc
136+
(Warnings.Bs_derive_warning text)
137+
133138

134139
let ident_or_record_as_config
135140
loc
@@ -156,11 +161,11 @@ let ident_or_record_as_config
156161
->
157162
({Asttypes.txt = name ; loc}, Some y)
158163
| _ ->
159-
Location.raise_errorf ~loc "Qualified label is not allood"
164+
Location.raise_errorf ~loc "Qualified label is not allowed"
160165
)
161166

162167
| Some _ ->
163-
Location.raise_errorf ~loc "with is not supported"
168+
unrecognizedConfigRecord loc "`with` is not supported, discarding"; []
164169
end
165170
| PStr [
166171
{pstr_desc =
@@ -174,7 +179,7 @@ let ident_or_record_as_config
174179
] -> [ {Asttypes.txt ; loc = lloc}, None]
175180
| PStr [] -> []
176181
| _ ->
177-
Location.raise_errorf ~loc "this is not a valid record config"
182+
unrecognizedConfigRecord loc "invalid attribute config-record, ignoring"; []
178183

179184

180185

jscomp/syntax/ast_payload.mli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,10 @@ val empty : t
8383

8484
val table_dispatch :
8585
(Parsetree.expression option -> 'a) Map_string.t -> action -> 'a
86+
87+
(** Report to the user, as a warning, that the bs-attribute parser is bailing out. (This is to allow
88+
external ppx, like ppx_deriving, to pick up where the builtin ppx leave off.) *)
89+
val unrecognizedConfigRecord:
90+
Location.t ->
91+
string ->
92+
unit

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398616,6 +398616,13 @@ val empty : t
398616398616
val table_dispatch :
398617398617
(Parsetree.expression option -> 'a) Map_string.t -> action -> 'a
398618398618

398619+
(** Report to the user, as a warning, that the bs-attribute parser is bailing out. (This is to allow
398620+
external ppx, like ppx_deriving, to pick up where the builtin ppx leave off.) *)
398621+
val unrecognizedConfigRecord:
398622+
Location.t ->
398623+
string ->
398624+
unit
398625+
398619398626
end = struct
398620398627
#1 "ast_payload.ml"
398621398628
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -398750,6 +398757,11 @@ type action =
398750398757
*)
398751398758

398752398759

398760+
let unrecognizedConfigRecord loc text =
398761+
Location.prerr_warning
398762+
loc
398763+
(Warnings.Bs_derive_warning text)
398764+
398753398765

398754398766
let ident_or_record_as_config
398755398767
loc
@@ -398776,11 +398788,11 @@ let ident_or_record_as_config
398776398788
->
398777398789
({Asttypes.txt = name ; loc}, Some y)
398778398790
| _ ->
398779-
Location.raise_errorf ~loc "Qualified label is not allood"
398791+
Location.raise_errorf ~loc "Qualified label is not allowed"
398780398792
)
398781398793

398782398794
| Some _ ->
398783-
Location.raise_errorf ~loc "with is not supported"
398795+
unrecognizedConfigRecord loc "`with` is not supported, discarding"; []
398784398796
end
398785398797
| PStr [
398786398798
{pstr_desc =
@@ -398794,7 +398806,7 @@ let ident_or_record_as_config
398794398806
] -> [ {Asttypes.txt ; loc = lloc}, None]
398795398807
| PStr [] -> []
398796398808
| _ ->
398797-
Location.raise_errorf ~loc "this is not a valid record config"
398809+
unrecognizedConfigRecord loc "invalid attribute config-record, ignoring"; []
398798398810

398799398811

398800398812

@@ -402807,6 +402819,7 @@ val notApplicable:
402807402819
unit
402808402820

402809402821
val invalid_config : Parsetree.expression -> 'a
402822+
402810402823
end = struct
402811402824
#1 "ast_derive_util.ml"
402812402825
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398616,6 +398616,13 @@ val empty : t
398616398616
val table_dispatch :
398617398617
(Parsetree.expression option -> 'a) Map_string.t -> action -> 'a
398618398618

398619+
(** Report to the user, as a warning, that the bs-attribute parser is bailing out. (This is to allow
398620+
external ppx, like ppx_deriving, to pick up where the builtin ppx leave off.) *)
398621+
val unrecognizedConfigRecord:
398622+
Location.t ->
398623+
string ->
398624+
unit
398625+
398619398626
end = struct
398620398627
#1 "ast_payload.ml"
398621398628
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -398750,6 +398757,11 @@ type action =
398750398757
*)
398751398758

398752398759

398760+
let unrecognizedConfigRecord loc text =
398761+
Location.prerr_warning
398762+
loc
398763+
(Warnings.Bs_derive_warning text)
398764+
398753398765

398754398766
let ident_or_record_as_config
398755398767
loc
@@ -398776,11 +398788,11 @@ let ident_or_record_as_config
398776398788
->
398777398789
({Asttypes.txt = name ; loc}, Some y)
398778398790
| _ ->
398779-
Location.raise_errorf ~loc "Qualified label is not allood"
398791+
Location.raise_errorf ~loc "Qualified label is not allowed"
398780398792
)
398781398793

398782398794
| Some _ ->
398783-
Location.raise_errorf ~loc "with is not supported"
398795+
unrecognizedConfigRecord loc "`with` is not supported, discarding"; []
398784398796
end
398785398797
| PStr [
398786398798
{pstr_desc =
@@ -398794,7 +398806,7 @@ let ident_or_record_as_config
398794398806
] -> [ {Asttypes.txt ; loc = lloc}, None]
398795398807
| PStr [] -> []
398796398808
| _ ->
398797-
Location.raise_errorf ~loc "this is not a valid record config"
398809+
unrecognizedConfigRecord loc "invalid attribute config-record, ignoring"; []
398798398810

398799398811

398800398812

@@ -402807,6 +402819,7 @@ val notApplicable:
402807402819
unit
402808402820

402809402821
val invalid_config : Parsetree.expression -> 'a
402822+
402810402823
end = struct
402811402824
#1 "ast_derive_util.ml"
402812402825
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.

lib/4.06.1/whole_compiler.ml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288146,6 +288146,13 @@ val empty : t
288146288146
val table_dispatch :
288147288147
(Parsetree.expression option -> 'a) Map_string.t -> action -> 'a
288148288148

288149+
(** Report to the user, as a warning, that the bs-attribute parser is bailing out. (This is to allow
288150+
external ppx, like ppx_deriving, to pick up where the builtin ppx leave off.) *)
288151+
val unrecognizedConfigRecord:
288152+
Location.t ->
288153+
string ->
288154+
unit
288155+
288149288156
end = struct
288150288157
#1 "ast_payload.ml"
288151288158
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -288280,6 +288287,11 @@ type action =
288280288287
*)
288281288288

288282288289

288290+
let unrecognizedConfigRecord loc text =
288291+
Location.prerr_warning
288292+
loc
288293+
(Warnings.Bs_derive_warning text)
288294+
288283288295

288284288296
let ident_or_record_as_config
288285288297
loc
@@ -288306,11 +288318,11 @@ let ident_or_record_as_config
288306288318
->
288307288319
({Asttypes.txt = name ; loc}, Some y)
288308288320
| _ ->
288309-
Location.raise_errorf ~loc "Qualified label is not allood"
288321+
Location.raise_errorf ~loc "Qualified label is not allowed"
288310288322
)
288311288323

288312288324
| Some _ ->
288313-
Location.raise_errorf ~loc "with is not supported"
288325+
unrecognizedConfigRecord loc "`with` is not supported, discarding"; []
288314288326
end
288315288327
| PStr [
288316288328
{pstr_desc =
@@ -288324,7 +288336,7 @@ let ident_or_record_as_config
288324288336
] -> [ {Asttypes.txt ; loc = lloc}, None]
288325288337
| PStr [] -> []
288326288338
| _ ->
288327-
Location.raise_errorf ~loc "this is not a valid record config"
288339+
unrecognizedConfigRecord loc "invalid attribute config-record, ignoring"; []
288328288340

288329288341

288330288342

@@ -405636,6 +405648,7 @@ val notApplicable:
405636405648
unit
405637405649

405638405650
val invalid_config : Parsetree.expression -> 'a
405651+
405639405652
end = struct
405640405653
#1 "ast_derive_util.ml"
405641405654
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.

0 commit comments

Comments
 (0)