Skip to content

Commit b738319

Browse files
committed
.resi tests
1 parent fdc694b commit b738319

6 files changed

Lines changed: 31 additions & 1 deletion

File tree

compiler/ml/typemod.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,9 @@ and transl_signature env sg =
870870
let trem, rem, final_env = transl_sig newenv srem in
871871
(mksig (Tsig_include incl) env loc :: trem, sg @ rem, final_env)
872872
| Psig_attribute x ->
873+
(* The frontend pre-pass already emitted @@ppwarning and malformed
874+
@@warning diagnostics; only thread the warning state here so the
875+
remaining signature items see the right settings. *)
873876
Builtin_attributes.warning_scope ~ppwarning:false
874877
~report_attribute_errors:false [x] (fun () ->
875878
let trem, rem, final_env = transl_sig env srem in
@@ -1605,6 +1608,8 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope =
16051608
Cmt_format.set_saved_types
16061609
(Cmt_format.Partial_structure_item str :: previous_saved_types);
16071610
let str_rem, sig_rem, final_env =
1611+
(* Floating warning-attribute diagnostics are handled in the frontend
1612+
pass; this scope only applies their effect to following items. *)
16081613
Builtin_attributes.warning_scope ~ppwarning:false
16091614
~report_attribute_errors:false [x] (fun () -> type_struct env srem)
16101615
in
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
Warning number 47
3+
/.../fixtures/malformed_warning_attribute.resi:1:1-9
4+
5+
1 │ @@warning(123)
6+
2 │
7+
3 │ let x: int
8+
9+
illegal payload for attribute 'warning'.
10+
A single string literal is expected
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
Warning number 22
3+
/.../fixtures/ppwarning_signature_attribute.resi:1:13-19
4+
5+
1 │ @@ppwarning("hello")
6+
2 │
7+
3 │ let x: int
8+
9+
hello
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@@warning(123)
2+
3+
let x: int
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@@ppwarning("hello")
2+
3+
let x: int

tests/build_tests/super_errors/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { bsc } = setup(import.meta.dirname);
1111
const expectedDir = path.join(import.meta.dirname, "expected");
1212

1313
const fixtures = readdirSync(path.join(import.meta.dirname, "fixtures")).filter(
14-
fileName => path.extname(fileName) === ".res",
14+
fileName => [".res", ".resi"].includes(path.extname(fileName)),
1515
);
1616

1717
const prefix = ["-w", "+A", "-bs-jsx", "4"];

0 commit comments

Comments
 (0)