This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,141 @@
|
|||
Test flags and compile_flags fields on melange.emit stanza
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.8)
|
||||
> (using melange 0.1)
|
||||
> EOF
|
||||
|
||||
Using flags field in melange.emit stanzas is not supported
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (melange.emit
|
||||
> (target output)
|
||||
> (emit_stdlib false)
|
||||
> (modules main)
|
||||
> (flags -w -14-26))
|
||||
> EOF
|
||||
|
||||
$ dune build @mel
|
||||
File "dune", line 5, characters 2-7:
|
||||
5 | (flags -w -14-26))
|
||||
^^^^^
|
||||
Error: Unknown field "flags"
|
||||
[1]
|
||||
|
||||
Adds a module that contains unused var (warning 26) and illegal backlash (warning 14)
|
||||
|
||||
$ cat > main.ml <<EOF
|
||||
> let t = "\e\n" in
|
||||
> print_endline "hello"
|
||||
> EOF
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (melange.emit
|
||||
> (target output)
|
||||
> (emit_stdlib false)
|
||||
> (modules main)
|
||||
> (alias mel))
|
||||
> EOF
|
||||
|
||||
Trying to build triggers both warnings
|
||||
|
||||
$ dune build @mel
|
||||
File "main.ml", line 1, characters 9-11:
|
||||
1 | let t = "\e\n" in
|
||||
^^
|
||||
Error (warning 14 [illegal-backslash]): illegal backslash escape in string.
|
||||
Hint: Single backslashes \ are reserved for escape sequences
|
||||
(\n, \r, ...). Did you check the list of OCaml escape sequences?
|
||||
To get a backslash character, escape it with a second backslash: \\.
|
||||
File "main.ml", line 1, characters 4-5:
|
||||
1 | let t = "\e\n" in
|
||||
^
|
||||
Error (warning 26 [unused-var]): unused variable t.
|
||||
[1]
|
||||
|
||||
Let's ignore them using compile_flags
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (melange.emit
|
||||
> (target output)
|
||||
> (modules main)
|
||||
> (emit_stdlib false)
|
||||
> (alias mel)
|
||||
> (compile_flags -w -14-26))
|
||||
> EOF
|
||||
|
||||
$ dune build @mel
|
||||
$ node _build/default/output/main.js
|
||||
hello
|
||||
|
||||
Can also pass flags from the env stanza. Let's go back to failing state:
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (melange.emit
|
||||
> (target output)
|
||||
> (emit_stdlib false)
|
||||
> (modules main)
|
||||
> (alias mel))
|
||||
> EOF
|
||||
|
||||
$ dune build @mel
|
||||
File "main.ml", line 1, characters 9-11:
|
||||
1 | let t = "\e\n" in
|
||||
^^
|
||||
Error (warning 14 [illegal-backslash]): illegal backslash escape in string.
|
||||
Hint: Single backslashes \ are reserved for escape sequences
|
||||
(\n, \r, ...). Did you check the list of OCaml escape sequences?
|
||||
To get a backslash character, escape it with a second backslash: \\.
|
||||
File "main.ml", line 1, characters 4-5:
|
||||
1 | let t = "\e\n" in
|
||||
^
|
||||
Error (warning 26 [unused-var]): unused variable t.
|
||||
[1]
|
||||
|
||||
Adding env stanza with both warnings silenced allows the build to pass successfully
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (env
|
||||
> (_
|
||||
> (melange.compile_flags -w -14-26)))
|
||||
> (melange.emit
|
||||
> (alias mel)
|
||||
> (target output)
|
||||
> (emit_stdlib false)
|
||||
> (modules main))
|
||||
> EOF
|
||||
|
||||
$ dune build @mel
|
||||
$ node _build/default/output/main.js
|
||||
hello
|
||||
|
||||
Warning 102 (Melange only) is available if explicitly set
|
||||
|
||||
$ cat > main.ml <<EOF
|
||||
> let compare a b = compare a b
|
||||
> EOF
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (melange.emit
|
||||
> (target output)
|
||||
> (modules main)
|
||||
> (emit_stdlib false)
|
||||
> (compile_flags -w +a-70))
|
||||
> EOF
|
||||
|
||||
$ dune build output/main.js
|
||||
File "main.ml", line 1, characters 18-29:
|
||||
1 | let compare a b = compare a b
|
||||
^^^^^^^^^^^
|
||||
Warning 102 [polymorphic-comparison-introduced]: Polymorphic comparison introduced (maybe unsafe)
|
||||
|
||||
But it is disabled by default
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (melange.emit
|
||||
> (target output)
|
||||
> (emit_stdlib false)
|
||||
> (modules main))
|
||||
> EOF
|
||||
|
||||
$ dune build output/main.js
|
||||
Loading…
Add table
Add a link
Reference in a new issue