Commit graph

329 commits

Author SHA1 Message Date
r00ster
b100e2ec2a std.fmt: improve @compileError message 2022-01-01 10:29:36 +02:00
Tom Manner
2dd7255713 Fixed typo in deprecation error for E format specifier where it would instead complain about a specifier of X. 2021-12-29 01:02:04 -05:00
Lee Cannon
85de022c56
allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
LemonBoy
51be575745 std: Fix endless loop in fmt impl
Apparently there's a stage1 bug that may sometimes lead to an endless
loop being generated when unrolling the fmt impl.

Closes #9961
2021-10-17 16:06:40 -04:00
Andrew Kelley
f3ebfcae38 Merge remote-tracking branch 'origin/master' into llvm13
Conflicts:

 * cmake/Findclang.cmake
 * cmake/Findlld.cmake
 * cmake/Findllvm.cmake

In master branch, more search paths were added to these files with "12"
in the path. In this commit I updated them to "13".

 * src/stage1/codegen.cpp
 * src/zig_llvm.cpp
 * src/zig_llvm.h

In master branch, ZigLLVMBuildCmpXchg is improved to add
`is_single_threaded`. However, the LLVM 13 C API has this already, and
in the llvm13 branch, ZigLLVMBuildCmpXchg is deleted in favor of the C
API. In this commit I updated stage2 to use the LLVM 13 C API rather
than depending on an improved ZigLLVMBuildCmpXchg.

Additionally, src/target.zig largestAtomicBits needed to be updated to
include the new m68k ISA.
2021-09-15 14:51:08 -07:00
Andrew Kelley
c05a20fc8c std: reorganization that allows new usingnamespace semantics
The proposal #9629 is now accepted, usingnamespace stays but no longer
puts identifiers in scope.
2021-09-01 17:54:06 -07:00
Andrew Kelley
303e1a062c re-enable mips behavior tests for vectors
closes #3317
2021-09-01 15:41:29 -07:00
Boo
ef39725055
Fix float formatting for 0.0 when precision is 0 (#9642) 2021-08-30 13:39:05 -04:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Dmitry Matveyev
b2e970d157
std.json: Add support for recursive objects to std.json.parse (#9307)
* Add support for recursive objects to std.json.parse

* Remove previously defined error set

* Try with function which returns an error set

* Don't analyze already inferred types

* Add comptime to inferred_type parameter

* Make ParseInternalError to accept only a single argument

* Add public `ParseError` for `parse` function

* Use error.Foo syntax for errors instead of a named error set

* Better formatting

* Update to latest code changes
2021-08-20 14:52:48 +03:00
Meghan
7e7d67d8ee
std.fmt: add support for printing slices strings (#9562) 2021-08-19 14:12:11 +03:00
Meghan
fcf2ce0ffe std.fmt: add name of type in unsupport format string compile error 2021-08-14 11:07:01 +03:00
Andrew Kelley
5103053977 compile errors test harness: support unknown file/line/column
This gets us 2 more passing compile error test cases.
2021-07-02 13:28:31 -07:00
Isaac Freund
f398ac3ee4 std/fmt: add fmtDurationSigned
When working with durations it often makes sense to use signed integers
and allow negative durations, and there is currently no nice way to
format these in std.fmt. This patch adds a simple wrapper for the
existing fmtDurtion to fit this need.
2021-06-27 12:54:31 +03:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Jacob G-W
641ecc260f std, src, doc, test: remove unused variables 2021-06-21 17:03:03 -07:00
Jarred Sumner
540b52931a Improve error message when std.fmt.format is missing arguments
Use fmt in fmt so the number in the error message is fmt'd
2021-06-13 10:33:49 +03:00
daurnimator
916b645fc1 Have std.fmt functions take case as an enum 2021-06-10 08:33:42 +03:00
Jakub Konka
e8e305b67c Re-enable multiple wasm32 vector tests
Fixes #5339
2021-06-09 23:54:23 -04:00
LemonBoy
ec4e67fb0e std: Better formatting of tuple types
Skip the useless type name and the numeric field names.
2021-06-08 21:02:56 +03:00
Isaac Freund
608bc1cbd5
stage2: disallow 1.e9 and 0x1.p9 as float literals
Instead require `1e9` and `0x1p9`, disallowing the trailing dot.

This change to the grammar is consistent with forbidding `1.` and `0x1.`
as float literals and ensures there is only one way to do things here.
2021-05-31 19:51:11 +00:00
Andrew Kelley
93dbf30dcf std.fmt: fix regressions from master
A previous commit from this branch incorrectly changed the usage of
`comptime` keyword, and broke the std lib tests. This commit adds
`comptime` to a few function calls, correcting the behavior.
2021-05-17 19:53:46 -07:00
Andrew Kelley
83677074f9 std: update regarding std.builtin reorganization
There are also some regressed std.fmt tests here and I haven't figured
out what's wrong yet.
2021-05-17 16:08:09 -07:00
Andrew Kelley
5619ce2406 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * doc/langref.html.in
 * lib/std/enums.zig
 * lib/std/fmt.zig
 * lib/std/hash/auto_hash.zig
 * lib/std/math.zig
 * lib/std/mem.zig
 * lib/std/meta.zig
 * test/behavior/alignof.zig
 * test/behavior/bitcast.zig
 * test/behavior/bugs/1421.zig
 * test/behavior/cast.zig
 * test/behavior/ptrcast.zig
 * test/behavior/type_info.zig
 * test/behavior/vector.zig

Master branch added `try` to a bunch of testing function calls, and some
lines also had changed how to refer to the native architecture and other
`@import("builtin")` stuff.
2021-05-08 14:45:21 -07:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Andrew Kelley
fc40d23723 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * build.zig
 * lib/std/array_list.zig
 * lib/std/c/ast.zig
 * lib/std/c/parse.zig
 * lib/std/os/bits/linux.zig
2021-05-05 10:48:22 -07:00
LemonBoy
9d409233b2 std: Implement hex float printing
The results have been cross-checked with LLVM's APFloat implementation
by randomly sampling the f32/f64 space, while the f16 one was completely
checked given the small size.
2021-05-05 12:37:40 -04:00
Andrew Kelley
d3ffacb55c AstGen: hook up hex float parsing to float literals
Thanks @LemonBoy!
2021-04-28 15:13:43 -07:00
Andrew Kelley
df24ce52b1 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted to take advantage of the new hex float parsing
code.
2021-04-28 14:57:38 -07:00
LemonBoy
55c58f226d std: Add a parser for hexadecimal floating point numbers
Should be good enough to unblock progress on the stage2 compiler.

Unifying this parser and the regular one (and perhaps rewrite it, #2207)
is left as an exercise for the reader.
2021-04-28 17:36:12 -04:00
jacob gw
ce41ddcd23 std: fix potential bug in parseInt 2021-04-22 22:42:46 -04:00
Andrew Kelley
93d1c2d6d4 std: fix compile errors caught by stage2 AstGen
Follow-up from 507a8096d2
2021-04-22 19:32:57 -07:00
Andrew Kelley
507a8096d2 std: fix compile errors caught by stage2 AstGen
* `comptime const` is redundant
 * don't use `extern enum`; specify a tag type.
   `extern enum` is only when you need tags to alias. But aliasing tags
   is a smell. I will be making a proposal shortly to remove `extern enum`
   from the language.
 * there is no such thing as `packed enum`.
 * instead of `catch |_|`, omit the capture entirely.
 * unused function definition with missing parameter name
 * using `try` outside of a function or test
2021-04-22 18:07:46 -07:00
jacob gw
b4aec0e31d stage2: make std.fmt.parseInt ignore _ 2021-04-20 17:08:05 -04:00
Andrew Kelley
429cd2b5dd std: change @import("builtin") to std.builtin 2021-04-15 19:06:39 -07:00
Jonathan Knezek
bbe6a0dddd Add a test & fix for std.fmt.fmtDuration 2021-03-28 15:44:15 +02:00
Jonathan Knezek
0447a2c041
Implement fmtDuration using Formatter (#8137)
* Implement fmtDuration using Formatter

Deprecate Duration, duration

* fmtDuration: Fixed ns remainder

* fmtDuration: Fixed visibility; removed [Dd]uration
2021-03-07 15:00:15 +02:00
LemonBoy
72664df491 std: Deprecate the B and Bi format specifiers
Following #8007 and #8137 let's get rid of the last weird format.
2021-03-07 14:58:45 +02:00
LemonBoy
cd7c870bd8 std: Deprecate 'x'/'X'/'e'/'E' special cases for u8 slices
Let's follow the road paved by the removal of 'z'/'Z', the Formatter
pattern is nice enough to let us remove the remaining four special cases
and declare u8 slices free from any special casing!
2021-03-01 15:33:10 -08:00
Andrew Kelley
5f35dc0c0d zig fmt the std lib 2021-02-24 21:29:23 -07:00
LemonBoy
057bf1afc9 std: Add more error checking in hexToBytes
Prevent the function from turning into an endless loop that may or may
not perform OOB accesses.
2021-02-21 12:19:03 +02:00
Jonathan Marler
a448210fcf remove z/Z format specifier deprecations
The z/Z format specifiers were merged last October (4 months ago).  They were then deprecated in January (just over a month ago).  This PR removes them altogether.
2021-02-21 11:55:21 +02:00
Jonathan Marler
1480c42806 require specifier for arrayish types 2021-02-09 22:25:52 -08:00
Dmitry Atamanov
290efc0747
Improve error messages in std.fmt (#7898) 2021-01-30 13:12:44 +02:00
Asherah Connor
e8740a90b9 complete {Z} deprecation in std.fmt.formatIntValue
formatZigEscapes doesn't exist any more.
2021-01-29 20:46:39 +02:00
Jay Petacat
a021c7b1b2 Move fmt.testFmt to testing.expectFmt 2021-01-12 18:13:29 -08:00
Jonathan Knezek
fc10c9c4ce
Add std.fmt.formatDuration and std.fmt.duration (#7297)
`formatDuration` works on a writer, and `duration` wraps a u64 to allow pleasant injection into format strings.
2021-01-11 19:15:56 -05:00
Jonathan Marler
31802c6c68 remove z/Z format specifiers
Zig's format system is flexible enough to add custom formatters.  This PR removes the new z/Z format specifiers that were added for printing Zig identifiers and replaces them with custom formatters.
2021-01-07 23:49:22 -08:00
LemonBoy
608a73efb1 Decrement max_depth when printing slice elements 2021-01-02 17:12:57 -07:00