Skip to content

Support -warn-error argument #6717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 17, 2024

Conversation

aspeddro
Copy link
Contributor

@aspeddro aspeddro commented Apr 6, 2024

Add supoort for -warn-error argument. Use for CI only.

If there is already a configuration for warnings as error in rescript.json the argument will be added at the end

"warnings": {
  "error": "+27"
}

Example: Disable warning 27, run rescript -warn-error -27 generate -warn-error +27-27, the last one wins.

Related #6713

@aspeddro aspeddro marked this pull request as ready for review April 6, 2024 15:19
Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work! Some remarks:

  1. When passing an invalid an invalid argument like rescript -warn-error 32 instead of rescript -warn-error +32, I get the following error message:
Fatal error: exception Stdlib.Arg.Bad("Ill-formed list of warnings")

Maybe we could print a nicer error message in this case.

  1. I tested this and it did not work for me in a subpackage in a monorepo setup.

" -ws [host]:port set up host & port for WebSocket build notifications\n" +
" -verbose Set the output to be verbose\n" +
" -with-deps *deprecated* This is the default behavior now. This option will be removed in a future release\n" +
" -warn-error Enable warnings as error\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unclear here that a list of warning codes is needed as an argument (and what format this list needs to have).

@aspeddro aspeddro force-pushed the add-warn-error-ninja-rule branch from a1d40fb to 1f03d90 Compare April 9, 2024 01:57
@aspeddro
Copy link
Contributor Author

The new error message
image

Argument description now is

-warn-error  Warning numbers and whether to turn it into error or no

Do you have an example of a monorepo?

@fhammerschmidt
Copy link
Member

@cknitt
Copy link
Member

cknitt commented Apr 13, 2024

@aspeddro Are you able to reproduce the problem with subpackages in the monorepo that @fhammerschmidt linked to or do you need a different example project?

@aspeddro
Copy link
Contributor Author

I got an error installing local package with yarn

yarn add ~/Desktop/projects/rescript-compiler

Range Error: File size (2253956185) is greater than 2 GiB
    at new NodeError (node:internal/errors:405:5)
    at FSReqCallback.readFileAfterStat [as oncomplete] (node:fs:351:11)

I made a small example here

./node_modules/.bin/rescript build -with-deps -warn-error +110

Dependency pinned on shared
rescript: [1/3] src/Shared.ast
FAILED: src/Shared.ast

  Warning number 110 (configured as error) 
  /tmp/todo-monorepo-test/shared/src/Shared.res:1:21-25

  1 │ let add = (_, _) => %todo
  2 │ 

  Todo found.

  This code is not implemented yet and will crash at runtime. Make sure you implement this before runnin
g the code.

FAILED: cannot make progress due to previous errors.
Failure: /home/pedro/Desktop/projects/rescript-compiler/linux/ninja.exe 
Location: /tmp/todo-monorepo-test/node_modules/shared/lib/bs

@cknitt
Copy link
Member

cknitt commented Apr 16, 2024

Retested with a monorepo, works fine now! 🎉 Thanks a lot!

@aspeddro aspeddro force-pushed the add-warn-error-ninja-rule branch from ad7ecfc to 87a1387 Compare April 16, 2024 20:03
@cknitt cknitt merged commit a1c1d2b into rescript-lang:11.0_release Apr 17, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants