Commit Graph

1028 Commits

Author SHA1 Message Date
Manlio Perillo
17d85a72c4
langref: add missing ReleaseSmall when describing unreachable (#13909)
Add a missing ReleaseSmall when describing unreachable in the try
section and the unreachable entry in the Keyword Reference section.

Additionally, transform Debug, ReleaseSafe, ReleaseFast and ReleaseSmall
into links in the try section.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2022-12-13 15:02:17 -05:00
Manlio Perillo
89a9e927ad langref: improve the test_fn_reflection.zig doctest
Currently, the test_fn_reflection.zig doctest has an example of
.Fn.is_var_args.  This example can confuse the reader, since there is no
documentation about variadic functions and is_var_args is mainly used in
the compiler.

Remove the example with .Fn.is_var_args and add instead examples with
.Fn.return_type and .Fn.is_generic.
2022-12-13 15:00:42 -05:00
Manlio Perillo
1d5368fa35 langref: fix the slice_bounds.zig doctest
In the slice_bounds.zig doctest, the code "const slice = array[2..4]" is
incorrect, since the actual type is a pointer to an array, instead of a
slice.

Use a runtime know value to slice the array.
2022-12-13 14:59:46 -05:00
Manlio Perillo
21dafd7a54
langref: update comments in the slices.zig doctest (#13819)
In the slices.zig doctest, the code
`const all_together_slice = all_together[0..]` is incorrect, since the
actual type is a pointer to an array, instead of a slice.

Use a runtime-known value to slice the array.

In the next "slice pointer" test, clarify that slicing a slice to
produce a pointer to an array, requires comptime-known indexes, not just
constant indexes.
2022-12-13 14:58:52 -05:00
gettsu
175d018512
langref: avoid use of the term "enum variant" in enums.zig (#13847) 2022-12-12 23:49:42 -05:00
Manlio Perillo
09cc6b4b9e langref: improve the defer section
Split the original `defer.zig` doctest into 3 doctest:

  1. Document the defer keyword
  2. Document that the return statement is not allowed inside a defer
     expression
  3. Document the errdefer keyword

Replace "method" with "expression" in the text `defer method`.
2022-12-12 15:09:45 -05:00
Andrew Kelley
f1f17dc1c7
Merge pull request #13810 from r00ster91/old
Re-enable many previously failing tests and add test coverage
2022-12-10 15:07:51 -05:00
Manlio Perillo
f020734347 langref: remove HTML code from a shell node
Several <em> elements where added inside a shell node in the
Using--target-and--cflags section.  Remove them, since they are not
supposed to be handled by codegen.

For the original commit, see
0c091feb5 (Improve HTML semantics and a11y of language reference).

Fixes #13846
2022-12-10 14:39:40 +02:00
r00ster91
981cfd9c1c behavior and langref: reenable previously-regressed tests on aarch64 and powerpc64le
Closes #3282
2022-12-10 12:34:42 +01:00
Andrew Kelley
7637ac584f
Merge pull request #13821 from Vexu/eliminate-bound-fn
Eliminate `BoundFn` type from the language
2022-12-10 06:14:57 -05:00
Evin Yulo
e4874d842e Remove unneeded else unreachable in docgen.zig
See #707
2022-12-10 05:50:56 -05:00
Veikka Tuominen
9d93b2ccf1 Eliminate BoundFn type from the language
Closes #9484
2022-12-09 20:37:18 -07:00
Evin Yulo
d0172488b2 langref: update anonymous struct naming
Closes #13841
2022-12-09 19:59:47 +02:00
Manlio Perillo
65f35a76f9 langref: consistently use comptime-known and runtime-known 2022-12-09 18:24:40 +02:00
Manlio Perillo
505a21bcc5 langref: link "result location" to the "Result Location Semantics" section 2022-12-09 17:42:25 +02:00
Andrew Kelley
4451786c66 langref: update WASI preopens example 2022-12-06 12:27:28 -07:00
Andrew Kelley
6e52f36d46 langref: eliminate dependencies on stage1
This commit removes async/await/suspend/resume from the language
reference, as that feature does not yet work in the self-hosted
compiler.

We will be regressing this feature temporarily. Users of these language
features should stick with 0.10.x with the `-fstage1` flag until they
are restored.

See tracking issue #6025.
2022-12-01 15:28:44 -07:00
Andrew Kelley
8f079bad1f langref: acknowledge design flaw in the self-hosted compiler
See tracking issue #13724
2022-12-01 00:38:02 -07:00
Andrew Kelley
ceb0a632cf std.mem.Allocator: allow shrink to fail
closes #13535
2022-11-29 23:30:38 -07:00
Veikka Tuominen
17ff002bc0 Sema: improve safety panic for access of inactive union field 2022-11-29 21:44:08 +02:00
Jonathan Marler
58d9004cea packed struct fix example and clarify least to most significant ordering
The packed struct example was mistakenly applying endianness where it
shouldn't have been.  This wasn't being caught because we don't currently
test the examples on Big-endian systems.

I updated the test to remove the endianness where it didn't apply, and
added a new part of the test to demonstrate when it would apply.
2022-11-17 12:11:43 +02:00
Stevie Hryciw
32b97df50e langref: add appendix and explain 'container' terminology 2022-11-12 15:42:29 +02:00
Ganesan Rajagopal
88d2e4f66a langref.html.in: Simplify printing types in examples
zig stdlib fmt has a formatter for types which prints the type name.  So,
just use @TypeOf(type) instead of the longer @typeInfo(@TypeOf(type)).
2022-11-07 15:07:21 +02:00
Ali Chraghi
f5f1f8c666 all: rename i386 to x86 2022-11-04 00:09:27 +03:30
Andrew Kelley
0c1701768d Release 0.10.0 2022-10-31 10:24:38 -07:00
Andrew Kelley
a5c96c49d0 langref: mention void{} and empty blocks
closes #11112
closes #12496
2022-10-30 16:33:22 -07:00
Evin Yulo
09a96cdfce Fix #12822: Clarify langref about the behavior of undefined 2022-10-29 17:55:06 -04:00
Andrew Kelley
7d0dc2fd75 docgen: fix not escaping html in shell samples 2022-10-26 16:48:50 -07:00
Ali Chraghi
ca27055cda all: rename @maximum to @max and @minimum to @min 2022-10-18 14:15:16 +03:00
Jacob Young
f9192adaba llvm: fix lowering of non-byte-aligned field pointers
* When a field starts at some bit offset within a byte you need to load
   starting from that byte and shift, not starting from the next byte,
   so a rounded-down divide is required here, not a rounded-up one.
 * Remove paragraph from doc that no longer relates to anything.

Closes #12363
2022-10-15 14:19:40 -04:00
Robin Voetter
fb9a7dad17
add @addrSpaceCast to langref 2022-10-12 20:36:14 +02:00
Andrew Kelley
7ce1ee1bce
Merge pull request #13081 from r00ster91/docs
fix(text): hyphenation and other fixes
2022-10-12 05:26:11 -04:00
Veikka Tuominen
29ae6515f3 AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes
Closes #8532
2022-10-07 11:04:02 +03:00
r00ster91
654e0b6679 fix(text): hyphenation and other fixes 2022-10-05 21:19:10 +02:00
Andrew Kelley
ff534d2267
Merge pull request #12979 from Vexu/inline-switch
Implement inline switch cases
2022-10-03 23:43:09 -04:00
zooster
8eb96c32e3 docs(langref): fix outdated example 2022-10-03 22:41:48 -04:00
Techatrix
9a2f17f9f9
Docs: clarify unreachable for ReleaseSmall 2022-09-28 13:30:55 +03:00
Veikka Tuominen
17eea918ae langref: document inline switch 2022-09-27 18:33:23 +03:00
Zhora Trush
f7f15e99c4 Fix minor langref typos 2022-09-27 13:22:57 +03:00
Sage Hane
cae76d8293 langref: fix minor format error 2022-09-23 15:58:46 +02:00
John Simon
246a39c10e
langref: remove uses of old function pointer syntax 2022-09-23 12:08:30 +03:00
Eric Joldasov
a86c7b13a3 docgen: add f80 to builtin types 2022-09-14 20:08:34 -04:00
Andrew Kelley
1d041d3a10
Merge pull request #11664 from vincenzopalazzo/macros/docs
docs: add missed docs for some language feature like `defer` and `errdefer`
2022-09-14 19:26:28 -04:00
Veikka Tuominen
349d78a443 validate number literals in AstGen 2022-09-13 20:26:04 -04:00
Veikka Tuominen
e323cf1264 stage2: change how defers are stored in Zir
Storing defers this way has the benefits that the defer doesn't get
analyzed multiple times in AstGen, it takes up less space, and it
makes Sema aware of defers allowing for 'unreachable else prong'
error on error sets in generic code.

The disadvantage is that it is a bit more complex and errdefers with
payloads now emit a placeholder instruction (but those are rare).

Sema.zig before:
  Total ZIR bytes:    3.7794370651245117MiB
  Instructions:       238996 (2.051319122314453MiB)
  String Table Bytes: 89.2802734375KiB
  Extra Data Items:   430144 (1.640869140625MiB)
Sema.zig after:
  Total ZIR bytes:    3.3344192504882812MiB
  Instructions:       211829 (1.8181428909301758MiB)
  String Table Bytes: 89.2802734375KiB
  Extra Data Items:   374611 (1.4290275573730469MiB)
2022-09-12 01:52:44 -04:00
Andrew Kelley
3ee01c14ee std.zig.system.NativeTargetInfo: detection ignores self exe
Before, native glibc and dynamic linker detection attempted to use the
executable's own binary if it was dynamically linked to answer both the
C ABI question and the dynamic linker question. However, this could be
problematic on a system that uses a RUNPATH for the compiler binary,
locking it to an older glibc version, while system binaries such as
/usr/bin/env use a newer glibc version. The problem is that libc.so.6
glibc version will match that of the system while the dynamic linker
will match that of the compiler binary. Executables with these versions
mismatching will fail to run.

Therefore, this commit changes the logic to be the same regardless of
whether the compiler binary is dynamically or statically linked. It
inspects `/usr/bin/env` as an ELF file to find the answer to these
questions, or if there is a shebang line, then it chases the referenced
file recursively. If that does not provide the answer, then the function
falls back to defaults.

This commit also solves a TODO to remove an Allocator parameter to the
detect() function.
2022-09-08 20:52:49 -07:00
Jason Ho
2b92c5a23e
langref: tweak description of []T (#12319)
saying []T is a pointer is confusing because zig docs say there are two types of pointers (*T and [*]T). It is more clear to say that []T is a slice type which contains a [*]T pointer and a length.

Co-authored-by: Philipp Lühmann <47984692+luehmann@users.noreply.github.com>
2022-08-31 21:53:00 -04:00
Henrique Dante de Almeida
ee12264387 docs: Remove mention of type inference on anytype struct fields
It was removed from the language.
2022-08-27 20:34:13 +02:00
Andrew Kelley
2a96209c40
Merge pull request #12574 from Vexu/remove-bit-op-type-param
stage2+stage1: remove type parameter from bit builtins
2022-08-24 15:57:44 -04:00
Will Hawkins
5fd5950c92 Doc: Add hyphenation for top-level doc 2022-08-24 20:00:46 +03:00