authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-19 10:39:59-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-19 10:39:59-04:00
log051ee8e626111445c27d6c868cb0cdec6df7409e
treed144242d665fb7eff76dc3e561989146c84690a1
parentb483db486842c6d7d348b28ca09e56673e1bd800

change slicing syntax from ... to ..

See #359

40 files changed, 164 insertions(+), 158 deletions(-)

doc/langref.md+1-1
......@@ -133,7 +133,7 @@ FnCallExpression = "(" list(Expression, ",") ")"
133133
134134ArrayAccessExpression = "[" Expression "]"
135135
136SliceExpression = "[" Expression "..." option(Expression) "]"
136SliceExpression = "[" Expression ".." option(Expression) "]"
137137
138138ContainerInitExpression = "{" ContainerInitBody "}"
139139
example/cat/main.zig+2-2
......@@ -40,7 +40,7 @@ fn cat_stream(is: &io.InStream) -> %void {
4040 var buf: [1024 * 4]u8 = undefined;
4141
4242 while (true) {
43 const bytes_read = is.read(buf[0...]) %% |err| {
43 const bytes_read = is.read(buf[0..]) %% |err| {
4444 %%io.stderr.printf("Unable to read from stream: {}\n", @errorName(err));
4545 return err;
4646 };
......@@ -49,7 +49,7 @@ fn cat_stream(is: &io.InStream) -> %void {
4949 break;
5050 }
5151
52 io.stdout.write(buf[0...bytes_read]) %% |err| {
52 io.stdout.write(buf[0..bytes_read]) %% |err| {
5353 %%io.stderr.printf("Unable to write to stdout: {}\n", @errorName(err));
5454 return err;
5555 };
example/guess_number/main.zig+3-3
......@@ -8,7 +8,7 @@ pub fn main() -> %void {
88 %%io.stdout.printf("Welcome to the Guess Number Game in Zig.\n");
99
1010 var seed_bytes: [@sizeOf(usize)]u8 = undefined;
11 %%os.getRandomBytes(seed_bytes[0...]);
11 %%os.getRandomBytes(seed_bytes[0..]);
1212 const seed = std.mem.readInt(seed_bytes, usize, true);
1313 var rand = Rand.init(seed);
1414
......@@ -18,12 +18,12 @@ pub fn main() -> %void {
1818 %%io.stdout.printf("\nGuess a number between 1 and 100: ");
1919 var line_buf : [20]u8 = undefined;
2020
21 const line_len = io.stdin.read(line_buf[0...]) %% |err| {
21 const line_len = io.stdin.read(line_buf[0..]) %% |err| {
2222 %%io.stdout.printf("Unable to read from stdin: {}\n", @errorName(err));
2323 return err;
2424 };
2525
26 const guess = fmt.parseUnsigned(u8, line_buf[0...line_len - 1], 10) %% {
26 const guess = fmt.parseUnsigned(u8, line_buf[0..line_len - 1], 10) %% {
2727 %%io.stdout.printf("Invalid number.\n");
2828 continue;
2929 };
example/mix_o_files/base64.zig+2-2
......@@ -1,7 +1,7 @@
11const base64 = @import("std").base64;
22
33export fn decode_base_64(dest_ptr: &u8, dest_len: usize, source_ptr: &const u8, source_len: usize) -> usize {
4 const src = source_ptr[0...source_len];
5 const dest = dest_ptr[0...dest_len];
4 const src = source_ptr[0..source_len];
5 const dest = dest_ptr[0..dest_len];
66 return base64.decode(dest, src).len;
77}
src/parser.cpp+4-4
......@@ -284,7 +284,7 @@ static AstNode *ast_parse_param_decl(ParseContext *pc, size_t *token_index) {
284284 }
285285
286286 Token *ellipsis_tok = &pc->tokens->at(*token_index);
287 if (ellipsis_tok->id == TokenIdEllipsis) {
287 if (ellipsis_tok->id == TokenIdEllipsis3) {
288288 *token_index += 1;
289289 node->data.param_decl.is_var_args = true;
290290 } else {
......@@ -879,7 +879,7 @@ static AstNode *ast_parse_suffix_op_expr(ParseContext *pc, size_t *token_index,
879879
880880 Token *ellipsis_or_r_bracket = &pc->tokens->at(*token_index);
881881
882 if (ellipsis_or_r_bracket->id == TokenIdEllipsis) {
882 if (ellipsis_or_r_bracket->id == TokenIdEllipsis2) {
883883 *token_index += 1;
884884
885885 AstNode *node = ast_create_node(pc, NodeTypeSliceExpr, first_token);
......@@ -1730,7 +1730,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m
17301730/*
17311731SwitchExpression = "switch" "(" Expression ")" "{" many(SwitchProng) "}"
17321732SwitchProng = (list(SwitchItem, ",") | "else") "=>" option("|" option("*") Symbol "|") Expression ","
1733SwitchItem : Expression | (Expression "..." Expression)
1733SwitchItem = Expression | (Expression "..." Expression)
17341734*/
17351735static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
17361736 Token *switch_token = &pc->tokens->at(*token_index);
......@@ -1767,7 +1767,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo
17671767 } else for (;;) {
17681768 AstNode *expr1 = ast_parse_expression(pc, token_index, true);
17691769 Token *ellipsis_tok = &pc->tokens->at(*token_index);
1770 if (ellipsis_tok->id == TokenIdEllipsis) {
1770 if (ellipsis_tok->id == TokenIdEllipsis3) {
17711771 *token_index += 1;
17721772
17731773 AstNode *range_node = ast_create_node(pc, NodeTypeSwitchRange, ellipsis_tok);
src/tokenizer.cpp+8-3
......@@ -588,7 +588,7 @@ void tokenize(Buf *buf, Tokenization *out) {
588588 switch (c) {
589589 case '.':
590590 t.state = TokenizeStateSawDotDot;
591 set_token_id(&t, t.cur_tok, TokenIdEllipsis);
591 set_token_id(&t, t.cur_tok, TokenIdEllipsis2);
592592 break;
593593 default:
594594 t.pos -= 1;
......@@ -601,10 +601,14 @@ void tokenize(Buf *buf, Tokenization *out) {
601601 switch (c) {
602602 case '.':
603603 t.state = TokenizeStateStart;
604 set_token_id(&t, t.cur_tok, TokenIdEllipsis3);
604605 end_token(&t);
605606 break;
606607 default:
607 tokenize_error(&t, "invalid character: '%c'", c);
608 t.pos -= 1;
609 end_token(&t);
610 t.state = TokenizeStateStart;
611 continue;
608612 }
609613 break;
610614 case TokenizeStateSawGreaterThan:
......@@ -1436,7 +1440,8 @@ const char * token_name(TokenId id) {
14361440 case TokenIdDivEq: return "/=";
14371441 case TokenIdDot: return ".";
14381442 case TokenIdDoubleQuestion: return "??";
1439 case TokenIdEllipsis: return "...";
1443 case TokenIdEllipsis3: return "...";
1444 case TokenIdEllipsis2: return "..";
14401445 case TokenIdEof: return "EOF";
14411446 case TokenIdEq: return "=";
14421447 case TokenIdFatArrow: return "=>";
src/tokenizer.hpp+2-1
......@@ -40,7 +40,8 @@ enum TokenId {
4040 TokenIdDivEq,
4141 TokenIdDot,
4242 TokenIdDoubleQuestion,
43 TokenIdEllipsis,
43 TokenIdEllipsis3,
44 TokenIdEllipsis2,
4445 TokenIdEof,
4546 TokenIdEq,
4647 TokenIdFatArrow,
std/array_list.zig+2-2
......@@ -27,11 +27,11 @@ pub fn ArrayList(comptime T: type) -> type{
2727 }
2828
2929 pub fn toSlice(l: &Self) -> []T {
30 return l.items[0...l.len];
30 return l.items[0..l.len];
3131 }
3232
3333 pub fn toSliceConst(l: &const Self) -> []const T {
34 return l.items[0...l.len];
34 return l.items[0..l.len];
3535 }
3636
3737 pub fn append(l: &Self, item: &const T) -> %void {
std/base64.zig+5-5
......@@ -56,7 +56,7 @@ pub fn encodeWithAlphabet(dest: []u8, source: []const u8, alphabet: []const u8)
5656 out_index += 1;
5757 }
5858
59 return dest[0...out_index];
59 return dest[0..out_index];
6060}
6161
6262pub fn decodeWithAlphabet(dest: []u8, source: []const u8, alphabet: []const u8) -> []u8 {
......@@ -67,7 +67,7 @@ pub fn decodeWithAlphabet(dest: []u8, source: []const u8, alphabet: []const u8)
6767 ascii6[c] = u8(i);
6868 }
6969
70 return decodeWithAscii6BitMap(dest, source, ascii6[0...], alphabet[64]);
70 return decodeWithAscii6BitMap(dest, source, ascii6[0..], alphabet[64]);
7171}
7272
7373pub fn decodeWithAscii6BitMap(dest: []u8, source: []const u8, ascii6: []const u8, pad_char: u8) -> []u8 {
......@@ -115,7 +115,7 @@ pub fn decodeWithAscii6BitMap(dest: []u8, source: []const u8, ascii6: []const u8
115115 dest_index += 1;
116116 }
117117
118 return dest[0...dest_index];
118 return dest[0..dest_index];
119119}
120120
121121pub fn calcEncodedSize(source_len: usize) -> usize {
......@@ -174,11 +174,11 @@ fn testBase64Case(expected_decoded: []const u8, expected_encoded: []const u8) {
174174
175175 var buf: [100]u8 = undefined;
176176
177 const actual_decoded = decode(buf[0...], expected_encoded);
177 const actual_decoded = decode(buf[0..], expected_encoded);
178178 assert(actual_decoded.len == expected_decoded.len);
179179 assert(mem.eql(u8, expected_decoded, actual_decoded));
180180
181 const actual_encoded = encode(buf[0...], expected_decoded);
181 const actual_encoded = encode(buf[0..], expected_decoded);
182182 assert(actual_encoded.len == expected_encoded.len);
183183 assert(mem.eql(u8, expected_encoded, actual_encoded));
184184}
std/buf_map.zig+1-1
......@@ -58,7 +58,7 @@ pub const BufMap = struct {
5858
5959 fn free(self: &BufMap, value: []const u8) {
6060 // remove the const
61 const mut_value = @ptrCast(&u8, value.ptr)[0...value.len];
61 const mut_value = @ptrCast(&u8, value.ptr)[0..value.len];
6262 self.hash_map.allocator.free(mut_value);
6363 }
6464
std/buf_set.zig+1-1
......@@ -47,7 +47,7 @@ pub const BufSet = struct {
4747
4848 fn free(self: &BufSet, value: []const u8) {
4949 // remove the const
50 const mut_value = @ptrCast(&u8, value.ptr)[0...value.len];
50 const mut_value = @ptrCast(&u8, value.ptr)[0..value.len];
5151 self.hash_map.allocator.free(mut_value);
5252 }
5353
std/buffer.zig+5-5
......@@ -43,11 +43,11 @@ pub const Buffer = struct {
4343 }
4444
4545 pub fn toSlice(self: &Buffer) -> []u8 {
46 return self.list.toSlice()[0...self.len()];
46 return self.list.toSlice()[0..self.len()];
4747 }
4848
4949 pub fn toSliceConst(self: &const Buffer) -> []const u8 {
50 return self.list.toSliceConst()[0...self.len()];
50 return self.list.toSliceConst()[0..self.len()];
5151 }
5252
5353 pub fn resize(self: &Buffer, new_len: usize) -> %void {
......@@ -66,7 +66,7 @@ pub const Buffer = struct {
6666 pub fn append(self: &Buffer, m: []const u8) -> %void {
6767 const old_len = self.len();
6868 %return self.resize(old_len + m.len);
69 mem.copy(u8, self.list.toSlice()[old_len...], m);
69 mem.copy(u8, self.list.toSlice()[old_len..], m);
7070 }
7171
7272 pub fn appendByte(self: &Buffer, byte: u8) -> %void {
......@@ -80,14 +80,14 @@ pub const Buffer = struct {
8080
8181 pub fn startsWith(self: &const Buffer, m: []const u8) -> bool {
8282 if (self.len() < m.len) return false;
83 return mem.eql(u8, self.list.items[0...m.len], m);
83 return mem.eql(u8, self.list.items[0..m.len], m);
8484 }
8585
8686 pub fn endsWith(self: &const Buffer, m: []const u8) -> bool {
8787 const l = self.len();
8888 if (l < m.len) return false;
8989 const start = l - m.len;
90 return mem.eql(u8, self.list.items[start...], m);
90 return mem.eql(u8, self.list.items[start..], m);
9191 }
9292
9393 pub fn replaceContents(self: &const Buffer, m: []const u8) -> %void {
std/build.zig+1-1
......@@ -335,7 +335,7 @@ pub const Builder = struct {
335335 };
336336 self.addRPath(rpath);
337337 } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') {
338 const lib_path = word[2...];
338 const lib_path = word[2..];
339339 self.addLibPath(lib_path);
340340 } else {
341341 %%io.stderr.printf("Unrecognized C flag from NIX_LDFLAGS: {}\n", word);
std/cstr.zig+2-2
......@@ -20,11 +20,11 @@ pub fn cmp(a: &const u8, b: &const u8) -> i8 {
2020}
2121
2222pub fn toSliceConst(str: &const u8) -> []const u8 {
23 return str[0...len(str)];
23 return str[0..len(str)];
2424}
2525
2626pub fn toSlice(str: &u8) -> []u8 {
27 return str[0...len(str)];
27 return str[0..len(str)];
2828}
2929
3030test "cstr fns" {
std/debug.zig+3-3
......@@ -149,8 +149,8 @@ fn printLineFromFile(allocator: &mem.Allocator, out_stream: &io.OutStream, line_
149149 var column: usize = 1;
150150 var abs_index: usize = 0;
151151 while (true) {
152 const amt_read = %return f.read(buf[0...]);
153 const slice = buf[0...amt_read];
152 const amt_read = %return f.read(buf[0..]);
153 const slice = buf[0..amt_read];
154154
155155 for (slice) |byte| {
156156 if (line == line_info.line) {
......@@ -939,7 +939,7 @@ var some_mem: [100 * 1024]u8 = undefined;
939939var some_mem_index: usize = 0;
940940
941941fn globalAlloc(self: &mem.Allocator, n: usize) -> %[]u8 {
942 const result = some_mem[some_mem_index ... some_mem_index + n];
942 const result = some_mem[some_mem_index .. some_mem_index + n];
943943 some_mem_index += n;
944944 return result;
945945}
std/elf.zig+1-1
......@@ -91,7 +91,7 @@ pub const Elf = struct {
9191 elf.auto_close_stream = false;
9292
9393 var magic: [4]u8 = undefined;
94 %return elf.in_stream.readNoEof(magic[0...]);
94 %return elf.in_stream.readNoEof(magic[0..]);
9595 if (!mem.eql(u8, magic, "\x7fELF")) return error.InvalidFormat;
9696
9797 elf.is_64 = switch (%return elf.in_stream.readByte()) {
std/endian.zig+1-1
......@@ -15,6 +15,6 @@ pub fn swapIf(is_be: bool, comptime T: type, x: T) -> T {
1515
1616pub fn swap(comptime T: type, x: T) -> T {
1717 var buf: [@sizeOf(T)]u8 = undefined;
18 mem.writeInt(buf[0...], x, false);
18 mem.writeInt(buf[0..], x, false);
1919 return mem.readInt(buf, T, true);
2020}
std/fmt.zig+19-19
......@@ -38,14 +38,14 @@ pub fn format(context: var, output: fn(@typeOf(context), []const u8)->bool,
3838 '{' => {
3939 // TODO if you make this an if statement with `and` then it breaks
4040 if (start_index < i) {
41 if (!output(context, fmt[start_index...i]))
41 if (!output(context, fmt[start_index..i]))
4242 return false;
4343 }
4444 state = State.OpenBrace;
4545 },
4646 '}' => {
4747 if (start_index < i) {
48 if (!output(context, fmt[start_index...i]))
48 if (!output(context, fmt[start_index..i]))
4949 return false;
5050 }
5151 state = State.CloseBrace;
......@@ -123,7 +123,7 @@ pub fn format(context: var, output: fn(@typeOf(context), []const u8)->bool,
123123 },
124124 State.IntegerWidth => switch (c) {
125125 '}' => {
126 width = comptime %%parseUnsigned(usize, fmt[width_start...i], 10);
126 width = comptime %%parseUnsigned(usize, fmt[width_start..i], 10);
127127 if (!formatInt(args[next_arg], radix, uppercase, width, context, output))
128128 return false;
129129 next_arg += 1;
......@@ -135,7 +135,7 @@ pub fn format(context: var, output: fn(@typeOf(context), []const u8)->bool,
135135 },
136136 State.BufWidth => switch (c) {
137137 '}' => {
138 width = comptime %%parseUnsigned(usize, fmt[width_start...i], 10);
138 width = comptime %%parseUnsigned(usize, fmt[width_start..i], 10);
139139 if (!formatBuf(args[next_arg], width, context, output))
140140 return false;
141141 next_arg += 1;
......@@ -166,7 +166,7 @@ pub fn format(context: var, output: fn(@typeOf(context), []const u8)->bool,
166166 }
167167 }
168168 if (start_index < fmt.len) {
169 if (!output(context, fmt[start_index...]))
169 if (!output(context, fmt[start_index..]))
170170 return false;
171171 }
172172
......@@ -198,7 +198,7 @@ pub fn formatValue(value: var, context: var, output: fn(@typeOf(context), []cons
198198}
199199
200200pub fn formatAsciiChar(c: u8, context: var, output: fn(@typeOf(context), []const u8)->bool) -> bool {
201 return output(context, (&c)[0...1]);
201 return output(context, (&c)[0..1]);
202202}
203203
204204pub fn formatBuf(buf: []const u8, width: usize,
......@@ -210,7 +210,7 @@ pub fn formatBuf(buf: []const u8, width: usize,
210210 var leftover_padding = if (width > buf.len) (width - buf.len) else return true;
211211 const pad_byte: u8 = ' ';
212212 while (leftover_padding > 0) : (leftover_padding -= 1) {
213 if (!output(context, (&pad_byte)[0...1]))
213 if (!output(context, (&pad_byte)[0..1]))
214214 return false;
215215 }
216216
......@@ -234,7 +234,7 @@ fn formatIntSigned(value: var, base: u8, uppercase: bool, width: usize,
234234 const uint = @IntType(false, @typeOf(value).bit_count);
235235 if (value < 0) {
236236 const minus_sign: u8 = '-';
237 if (!output(context, (&minus_sign)[0...1]))
237 if (!output(context, (&minus_sign)[0..1]))
238238 return false;
239239 const new_value = uint(-(value + 1)) + 1;
240240 const new_width = if (width == 0) 0 else (width - 1);
......@@ -243,7 +243,7 @@ fn formatIntSigned(value: var, base: u8, uppercase: bool, width: usize,
243243 return formatIntUnsigned(uint(value), base, uppercase, width, context, output);
244244 } else {
245245 const plus_sign: u8 = '+';
246 if (!output(context, (&plus_sign)[0...1]))
246 if (!output(context, (&plus_sign)[0..1]))
247247 return false;
248248 const new_value = uint(value);
249249 const new_width = if (width == 0) 0 else (width - 1);
......@@ -269,24 +269,24 @@ fn formatIntUnsigned(value: var, base: u8, uppercase: bool, width: usize,
269269 break;
270270 }
271271
272 const digits_buf = buf[index...];
272 const digits_buf = buf[index..];
273273 const padding = if (width > digits_buf.len) (width - digits_buf.len) else 0;
274274
275275 if (padding > index) {
276276 const zero_byte: u8 = '0';
277277 var leftover_padding = padding - index;
278278 while (true) {
279 if (!output(context, (&zero_byte)[0...1]))
279 if (!output(context, (&zero_byte)[0..1]))
280280 return false;
281281 leftover_padding -= 1;
282282 if (leftover_padding == 0)
283283 break;
284284 }
285 mem.set(u8, buf[0...index], '0');
285 mem.set(u8, buf[0..index], '0');
286286 return output(context, buf);
287287 } else {
288 const padded_buf = buf[index - padding...];
289 mem.set(u8, padded_buf[0...padding], '0');
288 const padded_buf = buf[index - padding..];
289 mem.set(u8, padded_buf[0..padding], '0');
290290 return output(context, padded_buf);
291291 }
292292}
......@@ -304,7 +304,7 @@ const FormatIntBuf = struct {
304304 index: usize,
305305};
306306fn formatIntCallback(context: &FormatIntBuf, bytes: []const u8) -> bool {
307 mem.copy(u8, context.out_buf[context.index...], bytes);
307 mem.copy(u8, context.out_buf[context.index..], bytes);
308308 context.index += bytes.len;
309309 return true;
310310}
......@@ -350,14 +350,14 @@ const BufPrintContext = struct {
350350
351351fn bufPrintWrite(context: &BufPrintContext, bytes: []const u8) -> bool {
352352 mem.copy(u8, context.remaining, bytes);
353 context.remaining = context.remaining[bytes.len...];
353 context.remaining = context.remaining[bytes.len..];
354354 return true;
355355}
356356
357357pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: ...) -> []u8 {
358358 var context = BufPrintContext { .remaining = buf, };
359359 _ = format(&context, bufPrintWrite, fmt, args);
360 return buf[0...buf.len - context.remaining.len];
360 return buf[0..buf.len - context.remaining.len];
361361}
362362
363363pub fn allocPrint(allocator: &mem.Allocator, comptime fmt: []const u8, args: ...) -> %[]u8 {
......@@ -374,7 +374,7 @@ fn countSize(size: &usize, bytes: []const u8) -> bool {
374374
375375test "buf print int" {
376376 var buffer: [max_int_digits]u8 = undefined;
377 const buf = buffer[0...];
377 const buf = buffer[0..];
378378 assert(mem.eql(u8, bufPrintIntToSlice(buf, i32(-12345678), 2, false, 0), "-101111000110000101001110"));
379379 assert(mem.eql(u8, bufPrintIntToSlice(buf, i32(-12345678), 10, false, 0), "-12345678"));
380380 assert(mem.eql(u8, bufPrintIntToSlice(buf, i32(-12345678), 16, false, 0), "-bc614e"));
......@@ -391,7 +391,7 @@ test "buf print int" {
391391}
392392
393393fn bufPrintIntToSlice(buf: []u8, value: var, base: u8, uppercase: bool, width: usize) -> []u8 {
394 return buf[0...formatIntBuf(buf, value, base, uppercase, width)];
394 return buf[0..formatIntBuf(buf, value, base, uppercase, width)];
395395}
396396
397397test "parse u64 digit too big" {
std/io.zig+7-7
......@@ -113,7 +113,7 @@ pub const OutStream = struct {
113113 while (src_index < bytes.len) {
114114 const dest_space_left = self.buffer.len - self.index;
115115 const copy_amt = math.min(dest_space_left, bytes.len - src_index);
116 mem.copy(u8, self.buffer[self.index...], bytes[src_index...src_index + copy_amt]);
116 mem.copy(u8, self.buffer[self.index..], bytes[src_index..src_index + copy_amt]);
117117 self.index += copy_amt;
118118 assert(self.index <= self.buffer.len);
119119 if (self.index == self.buffer.len) {
......@@ -152,7 +152,7 @@ pub const OutStream = struct {
152152
153153 pub fn flush(self: &OutStream) -> %void {
154154 if (self.index != 0) {
155 %return os.posixWrite(self.fd, self.buffer[0...self.index]);
155 %return os.posixWrite(self.fd, self.buffer[0..self.index]);
156156 self.index = 0;
157157 }
158158 }
......@@ -236,13 +236,13 @@ pub const InStream = struct {
236236
237237 pub fn readByte(is: &InStream) -> %u8 {
238238 var result: [1]u8 = undefined;
239 %return is.readNoEof(result[0...]);
239 %return is.readNoEof(result[0..]);
240240 return result[0];
241241 }
242242
243243 pub fn readByteSigned(is: &InStream) -> %i8 {
244244 var result: [1]i8 = undefined;
245 %return is.readNoEof(([]u8)(result[0...]));
245 %return is.readNoEof(([]u8)(result[0..]));
246246 return result[0];
247247 }
248248
......@@ -256,7 +256,7 @@ pub const InStream = struct {
256256
257257 pub fn readInt(is: &InStream, is_be: bool, comptime T: type) -> %T {
258258 var bytes: [@sizeOf(T)]u8 = undefined;
259 %return is.readNoEof(bytes[0...]);
259 %return is.readNoEof(bytes[0..]);
260260 return mem.readInt(bytes, T, is_be);
261261 }
262262
......@@ -264,7 +264,7 @@ pub const InStream = struct {
264264 assert(size <= @sizeOf(T));
265265 assert(size <= 8);
266266 var input_buf: [8]u8 = undefined;
267 const input_slice = input_buf[0...size];
267 const input_slice = input_buf[0..size];
268268 %return is.readNoEof(input_slice);
269269 return mem.readInt(input_slice, T, is_be);
270270 }
......@@ -349,7 +349,7 @@ pub const InStream = struct {
349349
350350 var actual_buf_len: usize = 0;
351351 while (true) {
352 const dest_slice = buf.toSlice()[actual_buf_len...];
352 const dest_slice = buf.toSlice()[actual_buf_len..];
353353 const bytes_read = %return is.read(dest_slice);
354354 actual_buf_len += bytes_read;
355355
std/mem.zig+11-11
......@@ -31,7 +31,7 @@ pub const Allocator = struct {
3131 }
3232
3333 fn destroy(self: &Allocator, ptr: var) {
34 self.free(ptr[0...1]);
34 self.free(ptr[0..1]);
3535 }
3636
3737 fn alloc(self: &Allocator, comptime T: type, n: usize) -> %[]T {
......@@ -69,7 +69,7 @@ pub const IncrementingAllocator = struct {
6969 .reallocFn = realloc,
7070 .freeFn = free,
7171 },
72 .bytes = @intToPtr(&u8, addr)[0...capacity],
72 .bytes = @intToPtr(&u8, addr)[0..capacity],
7373 .end_index = 0,
7474 };
7575 },
......@@ -87,7 +87,7 @@ pub const IncrementingAllocator = struct {
8787 if (new_end_index > self.bytes.len) {
8888 return error.NoMem;
8989 }
90 const result = self.bytes[self.end_index...new_end_index];
90 const result = self.bytes[self.end_index..new_end_index];
9191 self.end_index = new_end_index;
9292 return result;
9393 }
......@@ -165,7 +165,7 @@ pub fn indexOf(comptime T: type, haystack: []const T, needle: []const T) -> ?usi
165165 var i: usize = 0;
166166 const end = haystack.len - needle.len;
167167 while (i <= end) : (i += 1) {
168 if (eql(T, haystack[i...i + needle.len], needle))
168 if (eql(T, haystack[i .. i + needle.len], needle))
169169 return i;
170170 }
171171 return null;
......@@ -253,7 +253,7 @@ test "mem.split" {
253253}
254254
255255pub fn startsWith(comptime T: type, haystack: []const T, needle: []const T) -> bool {
256 return if (needle.len > haystack.len) false else eql(T, haystack[0...needle.len], needle);
256 return if (needle.len > haystack.len) false else eql(T, haystack[0 .. needle.len], needle);
257257}
258258
259259const SplitIterator = struct {
......@@ -273,7 +273,7 @@ const SplitIterator = struct {
273273 while (self.index < self.s.len and self.s[self.index] != self.c) : (self.index += 1) {}
274274 const end = self.index;
275275
276 return self.s[start...end];
276 return self.s[start..end];
277277 }
278278
279279 /// Returns a slice of the remaining bytes. Does not affect iterator state.
......@@ -281,7 +281,7 @@ const SplitIterator = struct {
281281 // move to beginning of token
282282 var index: usize = self.index;
283283 while (index < self.s.len and self.s[index] == self.c) : (index += 1) {}
284 return self.s[index...];
284 return self.s[index..];
285285 }
286286};
287287
......@@ -320,16 +320,16 @@ test "testWriteInt" {
320320fn testWriteIntImpl() {
321321 var bytes: [4]u8 = undefined;
322322
323 writeInt(bytes[0...], u32(0x12345678), true);
323 writeInt(bytes[0..], u32(0x12345678), true);
324324 assert(eql(u8, bytes, []u8{ 0x12, 0x34, 0x56, 0x78 }));
325325
326 writeInt(bytes[0...], u32(0x78563412), false);
326 writeInt(bytes[0..], u32(0x78563412), false);
327327 assert(eql(u8, bytes, []u8{ 0x12, 0x34, 0x56, 0x78 }));
328328
329 writeInt(bytes[0...], u16(0x1234), true);
329 writeInt(bytes[0..], u16(0x1234), true);
330330 assert(eql(u8, bytes, []u8{ 0x00, 0x00, 0x12, 0x34 }));
331331
332 writeInt(bytes[0...], u16(0x1234), false);
332 writeInt(bytes[0..], u16(0x1234), false);
333333 assert(eql(u8, bytes, []u8{ 0x34, 0x12, 0x00, 0x00 }));
334334}
335335
std/net.zig+5-5
......@@ -34,7 +34,7 @@ const Connection = struct {
3434 const recv_ret = linux.recvfrom(c.socket_fd, buf.ptr, buf.len, 0, null, null);
3535 const recv_err = linux.getErrno(recv_ret);
3636 switch (recv_err) {
37 0 => return buf[0...recv_ret],
37 0 => return buf[0..recv_ret],
3838 errno.EINVAL => unreachable,
3939 errno.EFAULT => unreachable,
4040 errno.ENOTSOCK => return error.NotSocket,
......@@ -81,7 +81,7 @@ pub fn lookup(hostname: []const u8, out_addrs: []Address) -> %[]Address {
8181 //switch (parseIpLiteral(hostname)) {
8282 // Ok => |addr| {
8383 // out_addrs[0] = addr;
84 // return out_addrs[0...1];
84 // return out_addrs[0..1];
8585 // },
8686 // else => {},
8787 //};
......@@ -134,7 +134,7 @@ pub fn connectAddr(addr: &Address, port: u16) -> %Connection {
134134
135135pub fn connect(hostname: []const u8, port: u16) -> %Connection {
136136 var addrs_buf: [1]Address = undefined;
137 const addrs_slice = %return lookup(hostname, addrs_buf[0...]);
137 const addrs_slice = %return lookup(hostname, addrs_buf[0..]);
138138 const main_addr = &addrs_slice[0];
139139
140140 return connectAddr(main_addr, port);
......@@ -186,7 +186,7 @@ fn parseIp6(buf: []const u8) -> %Address {
186186 var result: Address = undefined;
187187 result.family = linux.AF_INET6;
188188 result.scope_id = 0;
189 const ip_slice = result.addr[0...];
189 const ip_slice = result.addr[0..];
190190
191191 var x: u16 = 0;
192192 var saw_any_digits = false;
......@@ -280,7 +280,7 @@ fn parseIp6(buf: []const u8) -> %Address {
280280
281281fn parseIp4(buf: []const u8) -> %u32 {
282282 var result: u32 = undefined;
283 const out_ptr = ([]u8)((&result)[0...1]);
283 const out_ptr = ([]u8)((&result)[0..1]);
284284
285285 var x: u8 = 0;
286286 var index: u8 = 0;
std/os/child_process.zig+2-2
......@@ -225,7 +225,7 @@ fn forkChildErrReport(fd: i32, err: error) -> noreturn {
225225const ErrInt = @IntType(false, @sizeOf(error) * 8);
226226fn writeIntFd(fd: i32, value: ErrInt) -> %void {
227227 var bytes: [@sizeOf(ErrInt)]u8 = undefined;
228 mem.writeInt(bytes[0...], value, true);
228 mem.writeInt(bytes[0..], value, true);
229229
230230 var index: usize = 0;
231231 while (index < bytes.len) {
......@@ -259,6 +259,6 @@ fn readIntFd(fd: i32) -> %ErrInt {
259259 index += amt_written;
260260 }
261261
262 return mem.readInt(bytes[0...], ErrInt, true);
262 return mem.readInt(bytes[0..], ErrInt, true);
263263}
264264
std/os/index.zig+18-18
......@@ -172,7 +172,7 @@ pub fn posixOpen(file_path: []const u8, flags: usize, perm: usize, allocator: ?&
172172 var need_free = false;
173173
174174 if (file_path.len < stack_buf.len) {
175 path0 = stack_buf[0...file_path.len + 1];
175 path0 = stack_buf[0..file_path.len + 1];
176176 } else if (allocator) |a| {
177177 path0 = %return a.alloc(u8, file_path.len + 1);
178178 need_free = true;
......@@ -311,7 +311,7 @@ pub fn posixExecve(exe_path: []const u8, argv: []const []const u8, env_map: &con
311311 while (it.next()) |search_path| {
312312 mem.copy(u8, path_buf, search_path);
313313 path_buf[search_path.len] = '/';
314 mem.copy(u8, path_buf[search_path.len + 1 ...], exe_path);
314 mem.copy(u8, path_buf[search_path.len + 1 ..], exe_path);
315315 path_buf[search_path.len + exe_path.len + 1] = 0;
316316 err = posix.getErrno(posix.execve(path_buf.ptr, argv_buf.ptr, envp_buf.ptr));
317317 assert(err > 0);
......@@ -352,11 +352,11 @@ pub fn getEnvMap(allocator: &Allocator) -> %BufMap {
352352 for (environ_raw) |ptr| {
353353 var line_i: usize = 0;
354354 while (ptr[line_i] != 0 and ptr[line_i] != '=') : (line_i += 1) {}
355 const key = ptr[0...line_i];
355 const key = ptr[0..line_i];
356356
357357 var end_i: usize = line_i;
358358 while (ptr[end_i] != 0) : (end_i += 1) {}
359 const value = ptr[line_i + 1...end_i];
359 const value = ptr[line_i + 1..end_i];
360360
361361 %return result.set(key, value);
362362 }
......@@ -367,13 +367,13 @@ pub fn getEnv(key: []const u8) -> ?[]const u8 {
367367 for (environ_raw) |ptr| {
368368 var line_i: usize = 0;
369369 while (ptr[line_i] != 0 and ptr[line_i] != '=') : (line_i += 1) {}
370 const this_key = ptr[0...line_i];
370 const this_key = ptr[0..line_i];
371371 if (!mem.eql(u8, key, this_key))
372372 continue;
373373
374374 var end_i: usize = line_i;
375375 while (ptr[end_i] != 0) : (end_i += 1) {}
376 const this_value = ptr[line_i + 1...end_i];
376 const this_value = ptr[line_i + 1..end_i];
377377
378378 return this_value;
379379 }
......@@ -417,7 +417,7 @@ pub fn symLink(allocator: &Allocator, existing_path: []const u8, new_path: []con
417417 mem.copy(u8, existing_buf, existing_path);
418418 existing_buf[existing_path.len] = 0;
419419
420 const new_buf = full_buf[existing_path.len + 1...];
420 const new_buf = full_buf[existing_path.len + 1..];
421421 mem.copy(u8, new_buf, new_path);
422422 new_buf[new_path.len] = 0;
423423
......@@ -456,10 +456,10 @@ pub fn atomicSymLink(allocator: &Allocator, existing_path: []const u8, new_path:
456456 var rand_buf: [12]u8 = undefined;
457457 const tmp_path = %return allocator.alloc(u8, new_path.len + base64.calcEncodedSize(rand_buf.len));
458458 defer allocator.free(tmp_path);
459 mem.copy(u8, tmp_path[0...], new_path);
459 mem.copy(u8, tmp_path[0..], new_path);
460460 while (true) {
461 %return getRandomBytes(rand_buf[0...]);
462 _ = base64.encodeWithAlphabet(tmp_path[new_path.len...], rand_buf, b64_fs_alphabet);
461 %return getRandomBytes(rand_buf[0..]);
462 _ = base64.encodeWithAlphabet(tmp_path[new_path.len..], rand_buf, b64_fs_alphabet);
463463 if (symLink(allocator, existing_path, tmp_path)) {
464464 return rename(allocator, tmp_path, new_path);
465465 } else |err| {
......@@ -510,9 +510,9 @@ pub fn copyFileMode(allocator: &Allocator, source_path: []const u8, dest_path: [
510510 var rand_buf: [12]u8 = undefined;
511511 const tmp_path = %return allocator.alloc(u8, dest_path.len + base64.calcEncodedSize(rand_buf.len));
512512 defer allocator.free(tmp_path);
513 mem.copy(u8, tmp_path[0...], dest_path);
514 %return getRandomBytes(rand_buf[0...]);
515 _ = base64.encodeWithAlphabet(tmp_path[dest_path.len...], rand_buf, b64_fs_alphabet);
513 mem.copy(u8, tmp_path[0..], dest_path);
514 %return getRandomBytes(rand_buf[0..]);
515 _ = base64.encodeWithAlphabet(tmp_path[dest_path.len..], rand_buf, b64_fs_alphabet);
516516
517517 var out_stream = %return io.OutStream.openMode(tmp_path, mode, allocator);
518518 defer out_stream.close();
......@@ -521,7 +521,7 @@ pub fn copyFileMode(allocator: &Allocator, source_path: []const u8, dest_path: [
521521 var in_stream = %return io.InStream.open(source_path, allocator);
522522 defer in_stream.close();
523523
524 const buf = out_stream.buffer[0...];
524 const buf = out_stream.buffer[0..];
525525 while (true) {
526526 const amt = %return in_stream.read(buf);
527527 out_stream.index = amt;
......@@ -539,7 +539,7 @@ pub fn rename(allocator: &Allocator, old_path: []const u8, new_path: []const u8)
539539 mem.copy(u8, old_buf, old_path);
540540 old_buf[old_path.len] = 0;
541541
542 const new_buf = full_buf[old_path.len + 1...];
542 const new_buf = full_buf[old_path.len + 1..];
543543 mem.copy(u8, new_buf, new_path);
544544 new_buf[new_path.len] = 0;
545545
......@@ -601,7 +601,7 @@ pub fn makePath(allocator: &Allocator, full_path: []const u8) -> %void {
601601
602602 var end_index: usize = resolved_path.len;
603603 while (true) {
604 makeDir(allocator, resolved_path[0...end_index]) %% |err| {
604 makeDir(allocator, resolved_path[0..end_index]) %% |err| {
605605 if (err == error.PathAlreadyExists) {
606606 // TODO stat the file and return an error if it's not a directory
607607 // this is important because otherwise a dangling symlink
......@@ -691,7 +691,7 @@ start_over:
691691 const full_entry_path = full_entry_buf.toSlice();
692692 mem.copy(u8, full_entry_path, full_path);
693693 full_entry_path[full_path.len] = '/';
694 mem.copy(u8, full_entry_path[full_path.len + 1...], entry.name);
694 mem.copy(u8, full_entry_path[full_path.len + 1..], entry.name);
695695
696696 %return deleteTree(allocator, full_entry_path);
697697 }
......@@ -856,6 +856,6 @@ pub fn readLink(allocator: &Allocator, pathname: []const u8) -> %[]u8 {
856856 result_buf = %return allocator.realloc(u8, result_buf, result_buf.len * 2);
857857 continue;
858858 }
859 return result_buf[0...ret_val];
859 return result_buf[0..ret_val];
860860 }
861861}
std/os/path.zig+15-15
......@@ -39,7 +39,7 @@ pub fn join(allocator: &Allocator, paths: ...) -> %[]u8 {
3939 inline while (true) {
4040 const arg = ([]const u8)(paths[path_i]);
4141 path_i += 1;
42 mem.copy(u8, buf[buf_index...], arg);
42 mem.copy(u8, buf[buf_index..], arg);
4343 buf_index += arg.len;
4444 if (path_i >= paths.len) break;
4545 if (buf[buf_index - 1] != sep) {
......@@ -48,7 +48,7 @@ pub fn join(allocator: &Allocator, paths: ...) -> %[]u8 {
4848 }
4949 }
5050
51 return buf[0...buf_index];
51 return buf[0..buf_index];
5252}
5353
5454test "os.path.join" {
......@@ -110,7 +110,7 @@ pub fn resolveSlice(allocator: &Allocator, paths: []const []const u8) -> %[]u8 {
110110 }
111111 %defer allocator.free(result);
112112
113 for (paths[first_index...]) |p, i| {
113 for (paths[first_index..]) |p, i| {
114114 var it = mem.split(p, '/');
115115 while (it.next()) |component| {
116116 if (mem.eql(u8, component, ".")) {
......@@ -126,7 +126,7 @@ pub fn resolveSlice(allocator: &Allocator, paths: []const []const u8) -> %[]u8 {
126126 } else {
127127 result[result_index] = '/';
128128 result_index += 1;
129 mem.copy(u8, result[result_index...], component);
129 mem.copy(u8, result[result_index..], component);
130130 result_index += component.len;
131131 }
132132 }
......@@ -137,7 +137,7 @@ pub fn resolveSlice(allocator: &Allocator, paths: []const []const u8) -> %[]u8 {
137137 result_index += 1;
138138 }
139139
140 return result[0...result_index];
140 return result[0..result_index];
141141}
142142
143143test "os.path.resolve" {
......@@ -153,24 +153,24 @@ fn testResolve(args: ...) -> []u8 {
153153
154154pub fn dirname(path: []const u8) -> []const u8 {
155155 if (path.len == 0)
156 return path[0...0];
156 return path[0..0];
157157 var end_index: usize = path.len - 1;
158158 while (path[end_index] == '/') {
159159 if (end_index == 0)
160 return path[0...1];
160 return path[0..1];
161161 end_index -= 1;
162162 }
163163
164164 while (path[end_index] != '/') {
165165 if (end_index == 0)
166 return path[0...0];
166 return path[0..0];
167167 end_index -= 1;
168168 }
169169
170170 if (end_index == 0 and path[end_index] == '/')
171 return path[0...1];
171 return path[0..1];
172172
173 return path[0...end_index];
173 return path[0..end_index];
174174}
175175
176176test "os.path.dirname" {
......@@ -202,11 +202,11 @@ pub fn basename(path: []const u8) -> []const u8 {
202202 end_index += 1;
203203 while (path[start_index] != '/') {
204204 if (start_index == 0)
205 return path[0...end_index];
205 return path[0..end_index];
206206 start_index -= 1;
207207 }
208208
209 return path[start_index + 1...end_index];
209 return path[start_index + 1..end_index];
210210}
211211
212212test "os.path.basename" {
......@@ -265,10 +265,10 @@ pub fn relative(allocator: &Allocator, from: []const u8, to: []const u8) -> %[]u
265265 }
266266 if (to_rest.len == 0) {
267267 // shave off the trailing slash
268 return result[0...result_index - 1];
268 return result[0..result_index - 1];
269269 }
270270
271 mem.copy(u8, result[result_index...], to_rest);
271 mem.copy(u8, result[result_index..], to_rest);
272272 return result;
273273 }
274274
......@@ -303,7 +303,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 {
303303 defer os.posixClose(fd);
304304
305305 var buf: ["/proc/self/fd/-2147483648".len]u8 = undefined;
306 const proc_path = fmt.bufPrint(buf[0...], "/proc/self/fd/{}", fd);
306 const proc_path = fmt.bufPrint(buf[0..], "/proc/self/fd/{}", fd);
307307
308308 return os.readLink(allocator, proc_path);
309309}
std/rand.zig+4-4
......@@ -39,7 +39,7 @@ pub const Rand = struct {
3939 return (r.rng.get() & 0b1) == 0;
4040 } else {
4141 var result: [@sizeOf(T)]u8 = undefined;
42 r.fillBytes(result[0...]);
42 r.fillBytes(result[0..]);
4343 return mem.readInt(result, T, false);
4444 }
4545 }
......@@ -48,12 +48,12 @@ pub const Rand = struct {
4848 pub fn fillBytes(r: &Rand, buf: []u8) {
4949 var bytes_left = buf.len;
5050 while (bytes_left >= @sizeOf(usize)) {
51 mem.writeInt(buf[buf.len - bytes_left...], r.rng.get(), false);
51 mem.writeInt(buf[buf.len - bytes_left..], r.rng.get(), false);
5252 bytes_left -= @sizeOf(usize);
5353 }
5454 if (bytes_left > 0) {
5555 var rand_val_array: [@sizeOf(usize)]u8 = undefined;
56 mem.writeInt(rand_val_array[0...], r.rng.get(), false);
56 mem.writeInt(rand_val_array[0..], r.rng.get(), false);
5757 while (bytes_left > 0) {
5858 buf[buf.len - bytes_left] = rand_val_array[@sizeOf(usize) - bytes_left];
5959 bytes_left -= 1;
......@@ -71,7 +71,7 @@ pub const Rand = struct {
7171 var rand_val_array: [@sizeOf(T)]u8 = undefined;
7272
7373 while (true) {
74 r.fillBytes(rand_val_array[0...]);
74 r.fillBytes(rand_val_array[0..]);
7575 const rand_val = mem.readInt(rand_val_array, T, false);
7676 if (rand_val < upper_bound) {
7777 return start + (rand_val % range);
std/sort.zig+3-3
......@@ -70,7 +70,7 @@ test "testSort" {
7070
7171 for (u8cases) |case| {
7272 var buf: [8]u8 = undefined;
73 const slice = buf[0...case[0].len];
73 const slice = buf[0..case[0].len];
7474 mem.copy(u8, slice, case[0]);
7575 sort(u8, slice, u8asc);
7676 assert(mem.eql(u8, slice, case[1]));
......@@ -87,7 +87,7 @@ test "testSort" {
8787
8888 for (i32cases) |case| {
8989 var buf: [8]i32 = undefined;
90 const slice = buf[0...case[0].len];
90 const slice = buf[0..case[0].len];
9191 mem.copy(i32, slice, case[0]);
9292 sort(i32, slice, i32asc);
9393 assert(mem.eql(i32, slice, case[1]));
......@@ -106,7 +106,7 @@ test "testSortDesc" {
106106
107107 for (rev_cases) |case| {
108108 var buf: [8]i32 = undefined;
109 const slice = buf[0...case[0].len];
109 const slice = buf[0..case[0].len];
110110 mem.copy(i32, slice, case[0]);
111111 sort(i32, slice, i32desc);
112112 assert(mem.eql(i32, slice, case[1]));
std/special/bootstrap.zig+2-2
......@@ -39,11 +39,11 @@ fn callMainAndExit() -> noreturn {
3939}
4040
4141fn callMain(argc: usize, argv: &&u8, envp: &?&u8) -> %void {
42 std.os.args.raw = argv[0...argc];
42 std.os.args.raw = argv[0..argc];
4343
4444 var env_count: usize = 0;
4545 while (envp[env_count] != null) : (env_count += 1) {}
46 std.os.environ_raw = @ptrCast(&&u8, envp)[0...env_count];
46 std.os.environ_raw = @ptrCast(&&u8, envp)[0..env_count];
4747
4848 std.debug.user_main_fn = root.main;
4949
std/special/build_runner.zig+3-3
......@@ -58,14 +58,14 @@ pub fn main() -> %void {
5858 while (arg_i < os.args.count()) : (arg_i += 1) {
5959 const arg = os.args.at(arg_i);
6060 if (mem.startsWith(u8, arg, "-D")) {
61 const option_contents = arg[2...];
61 const option_contents = arg[2..];
6262 if (option_contents.len == 0) {
6363 %%io.stderr.printf("Expected option name after '-D'\n\n");
6464 return usage(&builder, false, &io.stderr);
6565 }
6666 if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| {
67 const option_name = option_contents[0...name_end];
68 const option_value = option_contents[name_end + 1...];
67 const option_name = option_contents[0..name_end];
68 const option_value = option_contents[name_end + 1..];
6969 if (builder.addUserInputOption(option_name, option_value))
7070 return usage(&builder, false, &io.stderr);
7171 } else {
std/special/zigrt.zig+2-2
......@@ -9,10 +9,10 @@ export coldcc fn __zig_panic(message_ptr: &const u8, message_len: usize) -> nore
99 @setDebugSafety(this, false);
1010
1111 if (builtin.__zig_panic_implementation_provided) {
12 @import("@root").panic(message_ptr[0...message_len]);
12 @import("@root").panic(message_ptr[0..message_len]);
1313 } else if (builtin.os == builtin.Os.freestanding) {
1414 while (true) {}
1515 } else {
16 @import("std").debug.panic("{}", message_ptr[0...message_len]);
16 @import("std").debug.panic("{}", message_ptr[0..message_len]);
1717 }
1818}
test/cases/array.zig+1-1
......@@ -70,7 +70,7 @@ const Str = struct {
7070 a: []Sub,
7171};
7272test "setGlobalVarArrayViaSliceEmbeddedInStruct" {
73 var s = Str { .a = s_array[0...]};
73 var s = Str { .a = s_array[0..]};
7474
7575 s.a[0].b = 1;
7676 s.a[1].b = 2;
test/cases/cast.zig+4-4
......@@ -148,7 +148,7 @@ fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) -> []const u8 {
148148 return []const u8 {};
149149 }
150150
151 return slice[0...1];
151 return slice[0..1];
152152}
153153
154154test "implicitly cast from [N]T to ?[]const T" {
......@@ -177,13 +177,13 @@ fn gimmeErrOrSlice() -> %[]u8 {
177177test "peer type resolution: [0]u8, []const u8, and %[]u8" {
178178 {
179179 var data = "hi";
180 const slice = data[0...];
180 const slice = data[0..];
181181 assert((%%peerTypeEmptyArrayAndSliceAndError(true, slice)).len == 0);
182182 assert((%%peerTypeEmptyArrayAndSliceAndError(false, slice)).len == 1);
183183 }
184184 comptime {
185185 var data = "hi";
186 const slice = data[0...];
186 const slice = data[0..];
187187 assert((%%peerTypeEmptyArrayAndSliceAndError(true, slice)).len == 0);
188188 assert((%%peerTypeEmptyArrayAndSliceAndError(false, slice)).len == 1);
189189 }
......@@ -193,7 +193,7 @@ fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) -> %[]u8 {
193193 return []u8{};
194194 }
195195
196 return slice[0...1];
196 return slice[0..1];
197197}
198198
199199test "resolve undefined with integer" {
test/cases/const_slice_child.zig+1-1
......@@ -24,7 +24,7 @@ fn bar(argc: usize) {
2424 const args = %%debug.global_allocator.alloc([]const u8, argc);
2525 for (args) |_, i| {
2626 const ptr = argv[i];
27 args[i] = ptr[0...strlen(ptr)];
27 args[i] = ptr[0..strlen(ptr)];
2828 }
2929 foo(args);
3030}
test/cases/enum_with_members.zig+4-4
......@@ -19,9 +19,9 @@ test "enumWithMembers" {
1919 const b = ET.UINT { 42 };
2020 var buf: [20]u8 = undefined;
2121
22 assert(%%a.print(buf[0...]) == 3);
23 assert(mem.eql(u8, buf[0...3], "-42"));
22 assert(%%a.print(buf[0..]) == 3);
23 assert(mem.eql(u8, buf[0..3], "-42"));
2424
25 assert(%%b.print(buf[0...]) == 2);
26 assert(mem.eql(u8, buf[0...2], "42"));
25 assert(%%b.print(buf[0..]) == 2);
26 assert(mem.eql(u8, buf[0..2], "42"));
2727}
test/cases/eval.zig+2-2
......@@ -145,7 +145,7 @@ test "constSlice" {
145145 comptime {
146146 const a = "1234567890";
147147 assert(a.len == 10);
148 const b = a[1...2];
148 const b = a[1..2];
149149 assert(b.len == 1);
150150 assert(b[0] == '2');
151151 }
......@@ -255,7 +255,7 @@ test "callMethodOnBoundFnReferringToVarInstance" {
255255test "ptrToLocalArrayArgumentAtComptime" {
256256 comptime {
257257 var bytes: [10]u8 = undefined;
258 modifySomeBytes(bytes[0...]);
258 modifySomeBytes(bytes[0..]);
259259 assert(bytes[0] == 'a');
260260 assert(bytes[9] == 'b');
261261 }
test/cases/for.zig+3-3
......@@ -18,8 +18,8 @@ test "continueInForLoop" {
1818test "forLoopWithPointerElemVar" {
1919 const source = "abcdefg";
2020 var target: [source.len]u8 = undefined;
21 mem.copy(u8, target[0...], source);
22 mangleString(target[0...]);
21 mem.copy(u8, target[0..], source);
22 mangleString(target[0..]);
2323 assert(mem.eql(u8, target, "bcdefgh"));
2424}
2525fn mangleString(s: []u8) {
......@@ -53,5 +53,5 @@ test "basicForLoop" {
5353 buf_index += 1;
5454 }
5555
56 assert(mem.eql(u8, buffer[0...buf_index], expected_result));
56 assert(mem.eql(u8, buffer[0..buf_index], expected_result));
5757}
test/cases/misc.zig+6-6
......@@ -173,14 +173,14 @@ test "slicing" {
173173
174174 array[5] = 1234;
175175
176 var slice = array[5...10];
176 var slice = array[5..10];
177177
178178 if (slice.len != 5) unreachable;
179179
180180 const ptr = &slice[0];
181181 if (ptr[0] != 1234) unreachable;
182182
183 var slice_rest = array[10...];
183 var slice_rest = array[10..];
184184 if (slice_rest.len != 10) unreachable;
185185}
186186
......@@ -260,7 +260,7 @@ test "generic malloc free" {
260260}
261261const some_mem : [100]u8 = undefined;
262262fn memAlloc(comptime T: type, n: usize) -> %[]T {
263 return @ptrCast(&T, &some_mem[0])[0...n];
263 return @ptrCast(&T, &some_mem[0])[0..n];
264264}
265265fn memFree(comptime T: type, memory: []T) { }
266266
......@@ -396,7 +396,7 @@ test "C string concatenation" {
396396test "cast slice to u8 slice" {
397397 assert(@sizeOf(i32) == 4);
398398 var big_thing_array = []i32{1, 2, 3, 4};
399 const big_thing_slice: []i32 = big_thing_array[0...];
399 const big_thing_slice: []i32 = big_thing_array[0..];
400400 const bytes = ([]u8)(big_thing_slice);
401401 assert(bytes.len == 4 * 4);
402402 bytes[4] = 0;
......@@ -509,9 +509,9 @@ test "volatile load and store" {
509509
510510test "slice string literal has type []const u8" {
511511 comptime {
512 assert(@typeOf("aoeu"[0...]) == []const u8);
512 assert(@typeOf("aoeu"[0..]) == []const u8);
513513 const array = []i32{1, 2, 3, 4};
514 assert(@typeOf(array[0...]) == []const i32);
514 assert(@typeOf(array[0..]) == []const i32);
515515 }
516516}
517517
test/cases/slice.zig+2-2
......@@ -1,7 +1,7 @@
11const assert = @import("std").debug.assert;
22
3const x = @intToPtr(&i32, 0x1000)[0...0x500];
4const y = x[0x100...];
3const x = @intToPtr(&i32, 0x1000)[0..0x500];
4const y = x[0x100..];
55test "compile time slice of pointer to hard coded address" {
66 assert(usize(x.ptr) == 0x1000);
77 assert(x.len == 0x500);
test/cases/struct.zig+2-2
......@@ -305,7 +305,7 @@ test "packedArray24Bits" {
305305
306306 var bytes = []u8{0} ** (@sizeOf(FooArray24Bits) + 1);
307307 bytes[bytes.len - 1] = 0xaa;
308 const ptr = &([]FooArray24Bits)(bytes[0...bytes.len - 1])[0];
308 const ptr = &([]FooArray24Bits)(bytes[0..bytes.len - 1])[0];
309309 assert(ptr.a == 0);
310310 assert(ptr.b[0].field == 0);
311311 assert(ptr.b[1].field == 0);
......@@ -354,7 +354,7 @@ test "alignedArrayOfPackedStruct" {
354354 }
355355
356356 var bytes = []u8{0xbb} ** @sizeOf(FooArrayOfAligned);
357 const ptr = &([]FooArrayOfAligned)(bytes[0...bytes.len])[0];
357 const ptr = &([]FooArrayOfAligned)(bytes[0..bytes.len])[0];
358358
359359 assert(ptr.a[0].a == 0xbb);
360360 assert(ptr.a[0].b == 0xbb);
test/cases/struct_contains_slice_of_itself.zig+2-2
......@@ -27,12 +27,12 @@ test "struct contains slice of itself" {
2727 },
2828 Node {
2929 .payload = 3,
30 .children = other_nodes[0...],
30 .children = other_nodes[0..],
3131 },
3232 };
3333 const root = Node {
3434 .payload = 1234,
35 .children = nodes[0...],
35 .children = nodes[0..],
3636 };
3737 assert(root.payload == 1234);
3838 assert(root.children[0].payload == 1);
test/compile_errors.zig+2-2
......@@ -1112,7 +1112,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
11121112 cases.add("bogus method call on slice",
11131113 \\var self = "aoeu";
11141114 \\fn f(m: []const u8) {
1115 \\ m.copy(u8, self[0...], m);
1115 \\ m.copy(u8, self[0..], m);
11161116 \\}
11171117 \\export fn entry() -> usize { @sizeOf(@typeOf(f)) }
11181118 , ".tmp_source.zig:3:6: error: no member named 'copy' in '[]const u8'");
......@@ -1467,7 +1467,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
14671467 \\pub fn pass(in: []u8) -> []u8 {
14681468 \\ var out = &s_buffer;
14691469 \\ *out[0] = in[0];
1470 \\ return (*out)[0...1];
1470 \\ return (*out)[0..1];
14711471 \\}
14721472 \\
14731473 \\export fn entry() -> usize { @sizeOf(@typeOf(pass)) }