-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when lang versions have an ignored suffix
Syntax versions (the string after `lang dune` for example) are parsed with `Scanf.sscanf`. This only parses the longest matching prefix and ignored the rest of the string. So `lang dune 2.3.0` is silently interpreted as `2.3` and so is `lang dune 2.4suffix`. This PR adds a warning when there is a suffix. An error could break existing projects. The implementation adds a `%s` to match the suffix. This specifier stops on whitespace characters, but these can not appear in valid atoms. Signed-off-by: Etienne Millon <me@emillon.org>
- Loading branch information
Showing
3 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
If (lang dune) does not use a valid format, a warning is emitted: | ||
|
||
$ cat > dune-project << EOF | ||
> (lang dune 2.3.0) | ||
> EOF | ||
|
||
$ dune build | ||
File "dune-project", line 1, characters 11-16: | ||
1 | (lang dune 2.3.0) | ||
^^^^^ | ||
Warning: The ".0" part is ignored here. | ||
This version is parsed as just 2.3. | ||
|
||
$ cat > dune-project << EOF | ||
> (lang dune 2.4suffix) | ||
> EOF | ||
|
||
$ dune build | ||
File "dune-project", line 1, characters 11-20: | ||
1 | (lang dune 2.4suffix) | ||
^^^^^^^^^ | ||
Warning: The "suffix" part is ignored here. | ||
This version is parsed as just 2.4. | ||
|
||
Of course if the version is valid, no warning is emitted: | ||
|
||
$ cat > dune-project << EOF | ||
> (lang dune 2.2) | ||
> EOF | ||
|
||
$ dune build |