Skip to content

Commit 14069cf

Browse files
committed
tweaks
1 parent 58bdaea commit 14069cf

File tree

9 files changed

+30
-10
lines changed

9 files changed

+30
-10
lines changed

compiler/frontend/bs_builtin_ppx.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,13 @@ let structure_item_mapper (self : mapper) (str : Parsetree.structure_item) :
462462
Ast_attributes.has_unwrap_attr vb.pvb_attributes)
463463
vbs
464464
in
465-
Bs_syntaxerr.err vb.pvb_pat.ppat_loc
466-
(LetUnwrap_not_supported_in_position `Toplevel)
465+
if not (Experimental_features.is_enabled Experimental_features.LetUnwrap)
466+
then
467+
Bs_syntaxerr.err vb.pvb_pat.ppat_loc
468+
(Experimental_feature_not_enabled LetUnwrap)
469+
else
470+
Bs_syntaxerr.err vb.pvb_pat.ppat_loc
471+
(LetUnwrap_not_supported_in_position `Toplevel)
467472
| Pstr_type (rf, tdcls) (* [ {ptype_attributes} as tdcl ] *) ->
468473
Ast_tdcls.handle_tdcls_in_stru self str rf tdcls
469474
| Pstr_primitive prim

compiler/frontend/bs_syntaxerr.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ let pp_error fmt err =
8888
| Experimental_feature_not_enabled feature ->
8989
Printf.sprintf
9090
"Experimental feature not enabled: %s. Enable it by setting \"%s\" to \
91-
true under \"experimentalFeatures\" in rescript.json"
91+
true under \"experimentalFeatures\" in rescript.json."
9292
(Experimental_features.to_string feature)
9393
(Experimental_features.to_string feature)
9494
| LetUnwrap_not_supported_in_position hint -> (

docs/docson/build-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@
491491
"properties": {
492492
"LetUnwrap": {
493493
"type": "boolean",
494-
"description": "Enable let? syntax."
494+
"description": "Enable `let?` syntax."
495495
}
496496
},
497497
"additionalProperties": false

rewatch/CompilerConfigurationSpec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ An object of feature flags to enable experimental compiler behavior. Only suppor
121121

122122
Currently supported features:
123123

124-
- LetUnwrap: Enable the `let?` transformation.
124+
- LetUnwrap: Enable `let?` syntax.
125125

126126
### Warnings
127127

tests/build_tests/super_errors/expected/feature_letunwrap_not_enabled.res.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
5 │ Ok()
99
6 │ }
1010

11-
Experimental feature not enabled: LetUnwrap. Enable it by setting "LetUnwrap" to true under "experimentalFeatures" in rescript.json
11+
Experimental feature not enabled: LetUnwrap. Enable it by setting "LetUnwrap" to true under "experimentalFeatures" in rescript.json.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
We've found a bug for you!
3-
/.../fixtures/let_unwrap_on_top_level.res:3:6-10
3+
/.../fixtures/let_unwrap_on_top_level.res:5:6-10
44

5-
1 │ let x = Ok(1)
6-
2 │
7-
3 │ let? Ok(_) = x
5+
3 │ let x = Ok(1)
86
4 │
7+
5 │ let? Ok(_) = x
8+
6 │
99

1010
`let?` is not allowed for top-level bindings.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/let_unwrap_on_top_level_not_enabled.res:3:6-10
4+
5+
1 │ let x = Ok(1)
6+
2 │
7+
3 │ let? Ok(_) = x
8+
4 │
9+
10+
Experimental feature not enabled: LetUnwrap. Enable it by setting "LetUnwrap" to true under "experimentalFeatures" in rescript.json.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@@config({flags: ["-enable-experimental", "LetUnwrap"]})
2+
13
let x = Ok(1)
24

35
let? Ok(_) = x
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let x = Ok(1)
2+
3+
let? Ok(_) = x

0 commit comments

Comments
 (0)