31 Commits

Author SHA1 Message Date
Marc Tiehuis
3c914c63a5 Remove #2725 workaround
These were no longer being hit after the copy-elision branch was merged.

Closes #2725.
2019-06-27 21:50:24 +12:00
Marc Tiehuis
08e8d30dd6 Add parsing of fill and alignment in std.format
These options are now available to use when printing, however nothing
currently makes use of these.
2019-06-25 17:11:18 +12:00
Marc Tiehuis
948dc7b304 Link formatting workaround to issue 2019-06-21 20:23:53 +12:00
Marc Tiehuis
11526b6e9d breaking: Add positional, precision and width support to std.fmt
This removes the odd width and precision specifiers found and replacing
them with the more consistent api described in #1358.

Take the following example:

    {1:5.9}

This refers to the first argument (0-indexed) in the argument list. It
will be printed with a minimum width of 5 and will have a precision of 9
(if applicable).

Not all types correctly use these parameters just yet. There are still
some missing gaps to fill in. Fill characters and alignment have yet to
be implemented.
2019-06-21 20:11:15 +12:00
Marc Tiehuis
d5d0942a0d Small cleanup of fmt.zig
Use inferred enum literals and split the large test case up.
2019-06-17 13:00:00 -04:00
Andrew Kelley
b735764898
different array literal syntax when inferring the size
old syntax:  []i32{1, 2, 3}
new syntax: [_]i32{1, 2, 3}

closes #1797
2019-06-09 19:26:32 -04:00
tgschultz
8eaf1387c7 Fix fmt.zig handling of slices of slices
Discovered while calling testing.expectError on an error union with payload [][]const u8. Even though the payload was not going to be printed, the current format handling caused a compile error anyway because it couldn't be casted to []const u8. The new handling treats a []u8 as a string but otherwise treats the slice as a pointer.
2019-05-29 20:46:08 -04:00
tgschultz
f9e7bd2682 std.meta/trait: def/definition => decl/declaration
TypeInfo: defs/Definition => decls/Declarations
2019-05-29 20:43:07 -04:00
Andrew Kelley
2f040a23c8
clean up references to os 2019-05-26 18:32:44 -04:00
Andrew Kelley
c1793d6106
zig fmt on the standard library 2019-05-12 12:56:01 -04:00
Ryan Liptak
205e501e42 std.fmt: add max_depth to avoid infinite recursion from self-references 2019-04-27 11:20:10 -04:00
Shritesh Bhattarai
6cc2d3938e support comptime_int in formatInt{,Value} 2019-04-05 11:11:04 -04:00
emekoi
b7aa289ae4 fixed broken casts in std 2019-03-31 16:47:34 -05:00
Andrew Kelley
af9ac0d548
better buffer length for formatIntUnsigned
see #1358
2019-03-19 10:11:28 -04:00
Andrew Kelley
080dd27157
breaking: fix @typeInfo handling of global error set type
`builtin.TypeInfo.ErrorSet` is now `?[]Error`
instead of `struct{errors:[]Error}`.

closes #1936
2019-03-14 11:57:56 -04:00
Andrew Kelley
e402455704
rename std lib files to new convention 2019-03-02 16:46:04 -05:00
Andrew Kelley
7f0620a20f partial implementation of printing floating point numbers with errol3
also add bitCast builtin function. closes #387
2017-06-14 00:24:25 -04:00
Andrew Kelley
0065eb7c80 std.fmt can print nullables, errors, and error unions 2017-05-23 18:38:41 -04:00
Andrew Kelley
051ee8e626 change slicing syntax from ... to ..
See #359
2017-05-19 10:39:59 -04:00
Andrew Kelley
b483db4868 typeId builtin instead of isInteger, isFloat, etc
closes #373
2017-05-17 12:26:35 -04:00
Andrew Kelley
8abcd94ece std.fmt.format prints bool values 2017-05-07 23:25:02 -04:00
Andrew Kelley
157af4332a builtin functions for division and remainder division
* add `@divTrunc` and `@divFloor` functions
 * add `@rem` and `@mod` functions
 * add compile error for `/` and `%` with signed integers
 * add `.bit_count` for float primitive types

closes #217
2017-05-06 23:13:12 -04:00
Andrew Kelley
698829b772 change while syntax
Old:

```
while (condition; expression) {}
```

New:

```
while (condition) : (expression) {}
```

This is in preparation to allow nullable and
error union types as the condition. See #357
2017-05-03 18:12:07 -04:00
Andrew Kelley
363d9038c9 zig build: organize build artifacts
closes #328
2017-04-30 18:56:24 -04:00
Josh Wolfe
c6605cba83 blocks check that their statements are void
closes #291

This changes the error message "return value ignored" to "expression value is ignored".
This is because this error also applies to {1;}, which has no function calls.

Also fix ignored expression values in std and test.
This caught a bug in debug.readAllocBytes where an early Eof error would have been missed.
See #219.
2017-04-23 21:15:15 -07:00
Andrew Kelley
407916cd2f rename @intType to @IntType to follow convention
closes #327
2017-04-18 00:05:09 -04:00
Andrew Kelley
6fbe1632d0 Update zig build system to support user defined options
* Fix assertion failure when switching on type.
   Closes #310
 * Update zig build system to support user defined options.
   See #204
 * fmt.format supports {sNNN} to set padding for a buffer arg.
 * add std.fmt.bufPrint and std.fmt.allocPrint
 * std.hash_map.HashMap.put returns the previous value
 * add std.mem.startsWith
2017-04-06 05:34:04 -04:00
Andrew Kelley
7ce753a16b replace "&&" and "||" with "and" and "or"
closes #272
2017-03-26 05:21:28 -04:00
Andrew Kelley
451ce09067 new unreachable syntax
* `noreturn` is the primitive type.
 * `unreachable` is a control flow keyword.
 * `@unreachable()` builtin function is deleted.

closes #214
2017-03-26 04:58:48 -04:00
Andrew Kelley
af536ac343 introduce new test syntax
* remove setFnTest builtin
 * add test "name" { ... } syntax
 * remove --check-unused argument. functions are always lazy now.
2017-03-16 16:02:35 -04:00
Andrew Kelley
47f267d25f break off some of std.io into std.fmt, generalize printf
closes #250
2017-03-09 19:12:15 -05:00