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. |
||
---|---|---|
.builds | ||
.github | ||
ci | ||
cmake | ||
deps | ||
doc | ||
lib | ||
src | ||
test | ||
tools | ||
.gitattributes | ||
.gitignore | ||
build.zig | ||
CMakeLists.txt | ||
LICENSE | ||
README.md |
A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
Resources
- Introduction
- Download & Documentation
- Chapter 0 - Getting Started | ZigLearn.org
- Community
- Contributing
- Code of Conduct
- Frequently Asked Questions
- Community Projects
Installation
- download a pre-built binary
- install from a package manager
- build from source
- bootstrap zig for any target
License
The ultimate goal of the Zig project is to serve users. As a first-order effect, this means users of the compiler, helping programmers to write better software. Even more important, however, are the end-users.
Zig is intended to be used to help end-users accomplish their goals. Zig should be used to empower end-users, never to exploit them financially, or to limit their freedom to interact with hardware or software in any way.
However, such problems are best solved with social norms, not with software licenses. Any attempt to complicate the software license of Zig would risk compromising the value Zig provides.
Therefore, Zig is available under the MIT (Expat) License, and comes with a humble request: use it to make software better serve the needs of end-users.
This project redistributes code from other projects, some of which have other licenses besides MIT. Such licenses are generally similar to the MIT license for practical purposes. See the subdirectories and files inside lib/ for more details.