mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 15:12:31 +00:00
9501ea688f
* Introduce the `--autofix` CLI flag when building an executable, object, or library. * Refactor std.zig.render to use a struct parameter to make it easier to add/remove fields from the struct. * Introduce a "Fixups" concept to std.zig.render which can perform edits while rendering code, while leaving the Ast read-only. * Add a fixup for adding a discard after a variable declaration. * Update the Module code to check for fixable errors after AstGen lowering. Improvements that need to be made before this can be merged: * Introduce an error for "pointless discard" and a fixup for it so that --autofix can undo the effects of itself when a variable becomes used. * Support local variables as well as local constants. * Support captures in addition to local variables and constants. * Integrate properly with incremental compilation. * Integrate with the Zig build system. * Distinguish between AstGen errors that can be autofixed and those that cannot. * Remove std.debug.print statements. * Only perform fixups when all errors are autofixable errors. However, suppress all autofixable errors when reporting errors with --autofix. The purpose of this feature is to satisfy two use cases that traditionally have been at odds: * Some people want the guarantee that all Zig code they read has the property that there are no unused locals. * Some people find no value from such errors and want to not have to deal with them. The problem with an `--allow-unused` flag is that people from the second group will use it, and then some projects will fail to compile without the flag enabled. I like to think of Zig as having "inline warnings". The warnings are there, inside your source code, next to the relevant lines, ready to be noticed by diffs, code reviews, and when refactoring. `--autofix` is a way for Zig to automatically insert inline warnings for those who wish to iterate quickly on a messy codebase. |
||
---|---|---|
.. | ||
compiler_rt | ||
docs | ||
include | ||
init-exe | ||
init-lib | ||
libc | ||
libcxx | ||
libcxxabi | ||
libunwind | ||
std | ||
tsan | ||
build_runner.zig | ||
c.zig | ||
compiler_rt.zig | ||
ssp.zig | ||
test_runner.zig |