raz / commit 65ec213a

commit
65ec213aa085972b480692a9b810ba1d898fd477
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
73f95268
Report 10.22.1: what is an error and what is free; messages and warnings to the guide

patch · log

2 files changed, +35 -29

doc/compiler.md (history) modified +13 -3

@@ -1432,8 +1432,17 @@
14321432 `X.linux.raz`, `X.x86_64.raz` and `X.raz`, in that order, and takes
14331433 the first found (`moduleFile`, `Parse.raz`).
14341434 - **Errors.** Every error in a run is reported, up to 20 (`MaxErrors`,
1435- `Diag.raz`); then the compiler stops. Two errors at the same place
1436- are told as one. Any error is status 1.
1435+ `Diag.raz`); then the compiler stops. Each comes with its file, line
1436+ and column, the line of source with the offending part underlined
1437+ and, where they help, notes pointing at other places, such as where
1438+ a name is declared, and a suggestion, such as a name in reach spelled
1439+ almost alike. After an error the compiler skips the statement or
1440+ declaration it is in and goes on with the next; a name that isn't
1441+ declared is reported once, and nothing that follows from it. An error
1442+ in the text itself, such as a string left open, stops the compile,
1443+ and so does a module with errors, after it. Two errors at the same
1444+ place are told as one. Any error is status 1, and no executable is
1445+ written.
14371446 - **Warnings.** Of a declaration never used, or a variable only
14381447 assigned (`warn`, `Parse.raz`): not of what is exported, a name that
14391448 starts with `_`, an enumeration's names or a generic module's
@@ -1447,7 +1456,8 @@
14471456 `else`, a `match`, a `while true` or a `repeat ... until false`
14481457 with no `break`. So is a call standing on its own that drops a
14491458 result (`drops`, kept by `noteDrop` and told by `dropped`);
1450- `_ := f(x)` drops one on purpose. `-Werror` makes each an error.
1459+ `_ := f(x)` drops one on purpose. Warnings don't stop the compile;
1460+ `raz -Werror`, an option of this compiler's, makes each an error.
14511461 - **Registers for variables.** Up to five of a procedure's single
14521462 values, not reals, whose address is never taken, live in `rbx` and
14531463 `r12` to `r15`, a slice taking two of them, and up to four reals in

doc/raz.md (history) modified +22 -26

@@ -850,7 +850,8 @@
850850 result and drops the second. What is dropped is still evaluated as
851851 any expression is: its calls are made, and a volatile variable in it
852852 is read (section 7.6). A result dropped by a call standing on its own
853-is warned of (section 10); one dropped through `_` isn't.
853+is a lint an implementation may warn of (section 10); one dropped
854+through `_` says it is meant.
854855
855856 ### 7.2 Conditions and loops
856857
@@ -1071,7 +1072,7 @@
10711072 as `c` itself would, with a target for each: `a, b := try f(x);`.
10721073
10731074 As a statement, `try c;` drops the values of `c` that it has, and a
1074-dropped value is warned of as a call that drops a result is (section
1075+dropped value is a lint, as a call that drops a result is (section
10751076 10); `_ := try c;` and `a, _ := try c;` say it is meant (section 7.1).
10761077 The error is never dropped: `try` is the way of passing it on.
10771078
@@ -1311,24 +1312,18 @@
13111312 A); one that does makes the same program as if every module were
13121313 compiled together, and keeps one copy of each instance.
13131314
1314-**Messages.** The compiler reports an error with its file, line and
1315-column, the line of source with the offending part underlined, and,
1316-where they help, notes pointing at other places, such as where a name
1317-is declared, and a suggestion, such as a name in reach spelled almost
1318-alike. It goes on after an error to find the others, up to 20, and
1319-writes no executable. After an error it skips the statement or
1320-declaration the error is in and carries on with the next; a name that
1321-isn't declared is reported once, and nothing that follows from it is
1322-reported. An error in the text itself, such as a string left open,
1323-stops the compile, and so does a module with errors, after it.
1324-
1325-The compiler also warns of what is declared and never used: an import;
1326-a constant, type, variable or procedure that isn't exported; a
1327-parameter of a procedure written in raz. It warns of a variable that is
1328-assigned but never read, too, and of a call standing on its own that
1329-drops a result, as `Sys.write(fd, s);` does: `_ := Sys.write(fd, s);`
1330-says it is meant. A name that starts with `_` is never warned about.
1331-Warnings don't stop the compile; `raz -Werror` makes them errors.
1315+**Errors.** A program that breaks a rule of this report that says it
1316+is an error isn't a raz program, and an implementation must reject it:
1317+say what is wrong and make no executable. Such a rule is one whose
1318+breach would leave the program with no meaning this report can give: a
1319+mistake of types, a name that isn't declared or is declared twice, an
1320+assignment to what is read-only, a module that imports itself. A fault
1321+that is only a lint isn't an error: a name declared and never used, or
1322+a result that a call standing on its own drops (`Sys.write(fd, s);`,
1323+where `_ := Sys.write(fd, s);` says it is meant). A program with one is
1324+valid, and an implementation may warn of it. The text of its messages,
1325+how many it reports and which warnings it gives are its own (appendix
1326+A).
13321327
13331328 ## 11. The library
13341329
@@ -2037,7 +2032,7 @@
20372032 - **2026-10.13.** `Sys` gains writing without waiting, and waiting for
20382033 room to write (section 11).
20392034 - **2026-10.14.** The blank, `_`, drops a value or one of several
2040- results (section 7.1); a call that drops a result is warned of
2035+ results (section 7.1); a call that drops a result is a lint
20412036 (section 10).
20422037 - **2026-10.15.** `Math` gains `pow`, `ceil`, `round`, `log2`,
20432038 `log10`, `tan`, `asin`, `acos` and `atan`; `Sys` gains `space`
@@ -2105,11 +2100,12 @@
21052100 compiled code; either way the program stops with its message
21062101 (section 10).
21072102 - **Messages and warnings.** The text of the compiler's messages, how
2108- many errors it reports before it stops, and which warnings it gives
2109- (section 10). A program that is an error in this report is one in
2110- every implementation; the words that say so are free. So is what a
2111- program that fails says on standard error: conformance is judged by a
2112- program's standard output and exit status, never by its standard error.
2103+ many errors it reports before it stops, and which warnings it gives,
2104+ `-Werror` included (section 10). That a program that is an error in
2105+ this report is rejected isn't free; the words that say so are. So is
2106+ what a program that fails says on standard error: conformance is
2107+ judged by a program's standard output and exit status, never by its
2108+ standard error.
21132109 - **The command line.** How the compiler is run, its options, and
21142110 where its library lives (sections 1 and 3).
21152111