Previous wording made it seem like any signed or floating-point value would be allowed at comptime, whereas negative values do not work with `%`, and negative integers do not work with `/`.
In this commit, the code samples in the language reference have been changed to
use `std.testing.expect` rather than `std.debug.assert` when they are
written in `test` code. This will teach Zig learners best practices when
they write their own test code.
Not all uses of `std.debug.assert` have been replaced. There are examples where
using `assert` fits the context of the sample.
Using `std.debug.assert` in test code can lead to errors if running tests in
ReleaseFast mode. In ReleaseFast mode, the `unreachable` in `assert` is
undefined behavior. It is possible that `assert` always causes `zig test` to
pass thus possibly leading to incorrect test code outcomes. The goal is to
prevent incorrect code from passing test cases.
Closes#5836
* move the opaque section to after struct, enum, union, and add
hyperlinks
* improve the introduction of the zig build system. don't link to the
wiki.
* update to the latest zig init-exe example code
* rename headers to avoid redundant words such as "zig"
* simplify example code
* std.log: still print error messages in ReleaseSmall builds.
- when start code gets an error code from main, it uses std.log.err
to report the error. this resulted in a test failure because
ReleaseSmall wasn't printing `error: TheErrorCode` when an error
was returned from main. But that seems like it should keep working.
So I changed the std.log defaults. I plan to follow this up with a
proposal to change the names of and reduce the quantity of the
log levels.
* warning emitted when using -femit-h when using stage1 backend; fatal
log message when using -femit-h with self-hosted backend (because the
feature is not yet available)
* fix double `test-cli` build steps in zig's build.zig
* update docgen to use new CLI
* translate-c uses `-x c` and generates a temporary basename with a
`.h` extension. Otherwise clang reports an error.
* --show-builtin implies -fno-emit-bin
* restore the compile error for using an extern "c" function without
putting -lc on the build line. we have to know about the libc
dependency up front.
* Fix ReleaseFast and ReleaseSmall getting swapped when passing the
value to the stage1 backend.
* correct the zig0 CLI usage text.
* update test harness code to the new CLI.