aboutsummaryrefslogtreecommitdiff
path: root/doc/langref.html.in
AgeCommit message (Collapse)Author
2023-03-27docgen: improve the termColor functionManlio Perillo
Make the termColor function more robust, ensuring that the generated HTML classes are more consistent and that they are supported in the CSS. Add documentation about the ANSI codes generated by Zig, and remove the previous comment with the supported colors. Improve test coverage for the termColor function, and move the tests at the end of the file before the printShell tests. Rename the "term color" test to "term supported colors" and add an additional "term output from zig" test, using test data generated from the Zig compiler. Update the langref.html.in CSS to use the new names and remove incorrect or obsolete colors like .t0_1, .t37 and .t37_1. Fix support for the 1m color. Change font-weight to normal for the kbd element, to avoid both the command (like `zig build-exe`) and the first line of the error message having a bold font. Rename the "shell parsed" test to "printShell".
2023-03-23Two more examples of possible syntax when dealing with errors (#15042)Phil Eaton
Add an example of if with try without else switch; add example of catch with block returning value
2023-03-21langref: add missing return types to builtin functionsr00ster91
This should add all remaining missing return types to all builtin functions. For @clz, @ctz, and @popCount it uses anytype for the lack of a better alternative. We already use this return type for other builtin functions in the langref to indicate that the type is not always the same. It is not possible to use anytype as the return type for regular functions but builtin functions are special.
2023-03-13Resolve docs inconsistency with Overflow builtinsHashi364
In 41 (Undefined Behavior) . 5 (Integer Overflow) . 3 (Builtin Overflow Functions), it is stated that > These builtins return a bool of whether or not overflow occurred, as well as returning the overflowed bits: > * @addWithOverflow > * @subWithOverflow > * @mulWithOverflow > * @shlWithOverflow but in their definition says that it returns a `tuple`/`struct`. Example; `@addWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 }` Co-authored-by: zooster <r00ster91@proton.me>
2023-03-12langref: add missing comma in assembly expressionsTechatrix
2023-03-05langref: small clarification to `@trap`Andrew Kelley
2023-03-04Merge pull request #14782 from r00ster91/trapAndrew Kelley
add `@trap` builtin
2023-03-04fix doc Build Modetranquillity-codes
2023-03-04add @trap builtinr00ster91
This introduces a new builtin function that compiles down to something that results in an illegal instruction exception/interrupt. It can be used to exit a program abnormally. This implements the builtin for all backends.
2023-02-19Merge pull request #14671 from ziglang/multi-object-forAndrew Kelley
implement multi-object for loops
2023-02-19Correctly handle carriage return characters according to the spec (#12661)Tom Read Cutting
* Scan from line start when finding tag in tokenizer This resolves a crash that can occur for invalid bytes like carriage returns that are valid characters when not parsed from within literals. There are potentially other edge cases this could resolve as well, as the calling code for this function didn't account for any potential 'pending_invalid_tokens' that could be queued up by the tokenizer from within another state. * Fix carriage return crash in multiline string Follow the guidance of #38: > However CR directly before NL is interpreted as only a newline and not part of the multiline string. zig fmt will delete the CR. Zig fmt already had code for deleting carriage returns, but would still crash - now it no longer does so. Carriage returns encountered before line-feeds are now appropriately removed on program compilation as well. * Only accept carriage returns before line feeds Previous commit was much less strict about this, this more closely matches the desired spec of only allow CR characters in a CRLF pair, but not otherwise. * Fix CR being rejected when used as whitespace Missed this comment from ziglang/zig-spec#83: > CR used as whitespace, whether directly preceding NL or stray, is still unambiguously whitespace. It is accepted by the grammar and replaced by the canonical whitespace by zig fmt. * Add tests for carriage return handling
2023-02-18langref: update to new for loop syntaxAndrew Kelley
2023-02-15split `@qualCast` into `@constCast` and `@volatileCast`Veikka Tuominen
2023-02-13langref: make more examples testableManlio Perillo
Some examples using {#syntax_block|zig|...#} either have a valid syntax or it is easy to make the syntax valid. Update these example to use {#code_begin|syntax|...#}. Remove extra whitespace in the error_union_parsing_u64.zig example. Replace size_t with usize in the call_malloc_from_zig.zig example.
2023-02-04langref, tools: rename --single-threaded to -fsingle-threadedee7
Commit 40f5e5dfc60e ("CLI: introduce -fsingle-threaded/ -fno-single-threaded", 2021-12-01) removed the `--single-threaded` option, but didn't update all mentions of it. $ zig version 0.11.0-dev.1568+c9b957c93 $ zig build-exe --help | grep single -fsingle-threaded Code assumes there is only one thread -fno-single-threaded Code may not assume there is only one thread $ zig build-exe --single-threaded foo.zig error: unrecognized parameter: '--single-threaded'
2023-02-03langref: remove link to closed issue #4026Manlio Perillo
In the math builtin functions documentation, remove the link to issue https://github.com/ziglang/zig/issues/4026, since it was closed by https://github.com/ziglang/zig/pull/11532.
2023-02-01Merge pull request #14477 from Vexu/fixesAndrew Kelley
Improve `@ptrCast` errors, fix some bugs
2023-02-01langref: add paragraph and examples about indexing non-ASCII stringsJosh Holland
PR #10610 addressed most of the points from #1854. This additional paragraph and examples covers the OMISSIONS section clarifying issues about indexing into non-ASCII strings (whether valid UTF-8 or not). I think this finally closes #1854.
2023-01-31langref updates for new std.Build APIAndrew Kelley
2023-01-31combine std.build and std.build.Builder into std.BuildAndrew Kelley
I've been wanting to do this for along time.
2023-01-31update build.zig API usageAndrew Kelley
2023-01-30implement `@qualCast`Veikka Tuominen
2023-01-30Sema: add helpful notes to invalid `@ptrCast` operationsVeikka Tuominen
Closes #14474
2023-01-25langref: make "Type Coercion" subsections more consistentManlio Perillo
In the "Type Coercion" section, rename: - Coercion Float to Int => Float to Int - unions and enums => Unions and Enums - tuples to arrays => Tuples to Arrays
2023-01-25langref: add missing dot at the end of the paragraphManlio Perillo
In the "C Variadic Functions" section, add a missing dot at the end of the paragraph before the test_defining_variadic_function.zig example.
2023-01-25langref: update the documentation of @TypeManlio Perillo
@Type is currently available for Functions.
2023-01-25langref: improve test_coerce_unions_enums.zigManlio Perillo
Add more coercion examples to test_coerce_unions_enums.zig in the "Type Coercion: unions and enums" section.
2023-01-25langref: move paragraph inside the p elementManlio Perillo
In the "C Translation CLI" section, move the paragraph inside the p element. The current HTML is valid, but, as an example, a paragraph outside a p element is not handled correctly by the browser Inspect tool.
2023-01-23langref: remove extra curly bracket in the CSSManlio Perillo
In commit 3542dbf0ea5 (langref: add section numbers) I accidentally added an extra closing curly bracket at the end of the style element. Sorry for not validating the HTML file before creating the PR.
2023-01-23docgen: make the name required in the Code nodeManlio Perillo
Update the genToc funtion to make the name required in the Code node, and add an additional optional field for the expected error, to use with test_err, test_safety and obj_err. Update langref.html.in to ensure all code blocks have a name that - is unique, so that a doctest can be identified by it - is descriptive For test, test_err and test_safefy, ensure that the doctest name starts with "test_", excluding doctests in the "Zig Test" section and doctests that are imported by other doctests. Ensure that the indentation of code_begin and code_end blocks are consistent. Fix a typo in pointer_arthemtic.
2023-01-22langref: point 0.10.0 nav link to 0.10.1Andrew Kelley
2023-01-19langref: always start code on a separate line in a syntax_blockManlio Perillo
In a syntax_block the code always start on a separate code, expect for C, JavaScript, Peg and with Zig inline assembly. Ensure that the code starts on a separate line, even in cases where there is only one line. Ensure that the end_syntax_block is always on a separate line and that the indentation is consistent.
2023-01-18langref: use the term tuple in the Hello World sectionManlio Perillo
In the Hello World section, replace the term "anonymous struct literal" with tuple, when documenting the second argument of stdout.print().
2023-01-17langref: document UTF-8 BOM handlingManlio Perillo
The current compiler ignores the UTF-8 BOM if it is at the start of the file, and disallows it anywhere else. Document it in the Source Encoding section.
2023-01-17langref: add the new addrspace keywordManlio Perillo
Add the new addrspace keyword in the Keyword Reference section, without documentation. Move the linksection keyword in order to keep the keywords list sorted.
2023-01-10langref: fix unclosed and lonely tag (#14250)Techatrix
2023-01-03Document tuple syntaxEvin Yulo
Closes #13837
2022-12-29AstGen: make type sentinel expressions implicitly comptimeVeikka Tuominen
2022-12-27update uses of overflow arithmetic builtinsVeikka Tuominen
2022-12-27zig fmt: improve handling of comptime tuple fieldsVeikka Tuominen
2022-12-27langref: more explicitly document how enum overriding workszooster
2022-12-26update grammar in langrefVeikka Tuominen
Closes #14072
2022-12-19langref: add section numbersManlio Perillo
When reading a document with nested sections, it is not easy to discover the depth of the current section. Add support for nested section numbers, from the h2 to the h4 heading, in the format "lv1. ", "lv1.lv2. ", "lv1.lv2.lv3. ". The "Zig Version" and "Table of Content" sections are excluded. The section numbers are implemented in CSS, with the CSS rules declared inside a @media rule. Currently the @media rule targets all media.
2022-12-18Merge pull request #13914 from Vexu/variadicAndrew Kelley
implement defining C variadic functions
2022-12-18Merge pull request #13930 from r00ster91/renamingsVeikka Tuominen
std.builtin: renamings
2022-12-18langref: remove incorrect use of term 'literal'Evin Yulo
2022-12-17std.builtin: rename Type.UnionField and Type.StructField's field_type to typer00ster91
2022-12-17std.builtin: rename Type.Fn's args to paramsr00ster91
This was a poor naming choice; these are parameters, not arguments. Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.
2022-12-17std.builtin: rename Type.Fn.Param's arg_type to typer00ster91
It's the type of a parameter, not an argument, but the prefix is redundant either way.
2022-12-17implement defining C variadic functionsVeikka Tuominen