From 24bde46181985f55a1fd64459070c4d564798eed Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 20 Feb 2025 17:42:47 -0500 Subject: [PATCH] Change array syntax from [T; N] to array(T, N) (#4981) In line with the proposal in #4682, this changes the array syntax to be array(T, N). `array` is a builtin keyword which must be followed by parens containing two expressions and a separating comma. The array type expression is still fully builtin, it does not forward to a Core.Array library type yet. It merely adds the `ArrayType` instruction, as was done with the previous syntax. Followup work will change the instruction to reference to Core.Array, once the library type exists and can be used directly. --------- Co-authored-by: zygoloid --- examples/advent2024/day10_common.carbon | 2 +- examples/advent2024/day10_part1.carbon | 4 +- examples/advent2024/day10_part2.carbon | 4 +- examples/advent2024/day11_part2.carbon | 2 +- examples/advent2024/day12_common.carbon | 4 +- examples/advent2024/day12_part2.carbon | 8 +- examples/advent2024/day1_common.carbon | 2 +- examples/advent2024/day1_part1.carbon | 4 +- examples/advent2024/day1_part2.carbon | 4 +- examples/advent2024/day2_part2.carbon | 2 +- examples/advent2024/day4_common.carbon | 6 +- examples/advent2024/day4_part1.carbon | 2 +- examples/advent2024/day4_part2.carbon | 2 +- examples/advent2024/day5_common.carbon | 4 +- examples/advent2024/day6_common.carbon | 2 +- examples/advent2024/day7_common.carbon | 2 +- examples/advent2024/day8_common.carbon | 2 +- examples/advent2024/day8_part2.carbon | 8 +- examples/advent2024/day9_common.carbon | 2 +- examples/advent2024/sort.carbon | 6 +- examples/sieve.carbon | 2 +- toolchain/check/convert.cpp | 2 +- ... 0444b366b646a800d860d362876dec36afb41e42} | 2 +- ... 17dc6eb1bbb8fd9671f46aa63924cf1a76837a2c} | 4 +- ... 1c56a65ba702fd27f5a72caf9c5e9170312db350} | 4 +- ... 306f80d197d3d627368e752f1ad6aa42d2e89aa6} | 2 +- ... 310b6d61f64901b21169432ef6bbc13a2b602376} | 2 +- ... 48f161ebf1c515fbc92fc959814c40d6394b5360} | 2 +- ... 54dab9151ed3293f3aec67e58aa20e26aa632a98} | 2 +- ... b08132223d41827e2b8cd8f849ffb7ac4af4e993} | 2 +- ... b0e276497e7036c6b3c90deeff71a055256ed5e3} | 2 +- ... bb0ee9a7c7f604c41cfef744a974c6603df4b0db} | 2 +- ... dbd0b78b1bfd4878676ac3d882aee2b797d7af15} | 4 +- ... f2b43d44db5dec0cca4bc6fc63f487fabae1b941} | 2 +- ... f71cbd0475ddb41b78a0d439aa78ae1e2eec0df5} | 2 +- toolchain/check/handle_array.cpp | 28 +- toolchain/check/node_stack.h | 5 +- .../testdata/array/array_in_place.carbon | 38 +- .../testdata/array/array_vs_tuple.carbon | 66 +-- .../testdata/array/assign_return_value.carbon | 20 +- .../check/testdata/array/assign_var.carbon | 26 +- toolchain/check/testdata/array/base.carbon | 96 ++-- .../testdata/array/canonicalize_index.carbon | 142 +++--- .../testdata/array/fail_bound_negative.carbon | 42 +- .../testdata/array/fail_bound_overflow.carbon | 28 +- .../array/fail_incomplete_element.carbon | 8 +- .../testdata/array/fail_invalid_type.carbon | 24 +- .../testdata/array/fail_out_of_bound.carbon | 10 +- .../fail_out_of_bound_non_literal.carbon | 60 +-- .../testdata/array/fail_type_mismatch.carbon | 74 +-- .../array/fail_undefined_bound.carbon | 23 - .../testdata/array/function_param.carbon | 18 +- .../check/testdata/array/generic_empty.carbon | 26 +- toolchain/check/testdata/array/import.carbon | 2 +- .../testdata/array/index_not_literal.carbon | 60 +-- .../array/init_dependent_bound.carbon | 72 +-- .../check/testdata/array/nine_elements.carbon | 168 +++---- .../testdata/basics/numeric_literals.carbon | 12 +- .../value_with_type_through_access.carbon | 56 +-- .../check/testdata/builtins/int/and.carbon | 4 +- .../testdata/builtins/int/complement.carbon | 4 +- .../check/testdata/builtins/int/or.carbon | 4 +- .../check/testdata/builtins/int/sadd.carbon | 32 +- .../check/testdata/builtins/int/sdiv.carbon | 4 +- .../check/testdata/builtins/int/smod.carbon | 4 +- .../testdata/builtins/int/snegate.carbon | 36 +- .../check/testdata/builtins/int/ssub.carbon | 4 +- .../check/testdata/builtins/int/uadd.carbon | 36 +- .../check/testdata/builtins/int/udiv.carbon | 4 +- .../check/testdata/builtins/int/umod.carbon | 4 +- .../check/testdata/builtins/int/umul.carbon | 4 +- .../testdata/builtins/int/unegate.carbon | 36 +- .../check/testdata/builtins/int/usub.carbon | 4 +- .../check/testdata/builtins/int/xor.carbon | 4 +- toolchain/check/testdata/deduce/array.carbon | 460 +++++++++--------- .../check/testdata/eval/aggregate.carbon | 66 +-- .../check/testdata/eval/fail_aggregate.carbon | 118 ++--- toolchain/check/testdata/eval/symbolic.carbon | 44 +- .../testdata/function/builtin/call.carbon | 48 +- .../testdata/function/builtin/method.carbon | 60 +-- .../no_prelude/call_from_operator.carbon | 154 +++--- .../function/builtin/no_prelude/import.carbon | 90 ++-- .../declaration/fail_param_in_type.carbon | 14 +- .../function/generic/param_in_type.carbon | 40 +- .../function/generic/return_slot.carbon | 2 +- toolchain/check/testdata/if_expr/basic.carbon | 24 +- .../testdata/impl/assoc_const_self.carbon | 8 +- .../impl/fail_impl_bad_assoc_fn.carbon | 46 +- .../impl/fail_todo_use_assoc_const.carbon | 42 +- .../index/array_element_access.carbon | 38 +- .../check/testdata/index/expr_category.carbon | 138 +++--- .../index/fail_array_large_index.carbon | 16 +- .../index/fail_array_non_int_indexing.carbon | 16 +- .../fail_array_out_of_bound_access.carbon | 16 +- .../testdata/index/fail_expr_category.carbon | 4 +- .../index/fail_negative_indexing.carbon | 42 +- .../tuple/access/fail_non_tuple_access.carbon | 42 +- toolchain/diagnostics/diagnostic_kind.def | 2 +- toolchain/lex/lex.cpp | 2 +- toolchain/lex/lex.h | 3 +- .../lex/testdata/numeric_literals.carbon | 114 ++--- toolchain/lex/token_kind.def | 1 + toolchain/lex/tokenized_buffer.h | 5 +- .../testdata/array/array_in_place.carbon | 16 +- .../testdata/array/assign_return_value.carbon | 24 +- toolchain/lower/testdata/array/base.carbon | 50 +- toolchain/lower/testdata/array/field.carbon | 2 +- .../testdata/array/function_param.carbon | 2 +- .../testdata/basics/numeric_literals.carbon | 8 +- .../index/array_element_access.carbon | 38 +- toolchain/parse/handle_array_expr.cpp | 32 +- toolchain/parse/handle_expr.cpp | 2 +- toolchain/parse/node_kind.def | 5 +- toolchain/parse/state.def | 26 +- .../{with_length.carbon => basic.carbon} | 23 +- .../array/fail_require_close_bracket.carbon | 29 -- .../testdata/array/fail_require_semi.carbon | 30 -- .../parse/testdata/array/fail_syntax.carbon | 264 +++++++--- .../testdata/array/without_length.carbon | 26 - .../basics/fail_bracket_recovery.carbon | 41 +- .../testdata/basics/numeric_literals.carbon | 36 +- .../testdata/for/fail_square_brackets.carbon | 33 +- .../testdata/if/fail_square_brackets.carbon | 31 +- toolchain/parse/typed_nodes.h | 30 +- toolchain/parse/typed_nodes_test.cpp | 2 +- 125 files changed, 1912 insertions(+), 1889 deletions(-) rename toolchain/check/fuzzer_corpus/{dd0aadb8d4ae92d3f07fd7f03c9bfcdc88b1f6bc => 0444b366b646a800d860d362876dec36afb41e42} (92%) rename toolchain/check/fuzzer_corpus/{0e272375f1c866bb051eab5262ad87da60f5ce8c => 17dc6eb1bbb8fd9671f46aa63924cf1a76837a2c} (89%) rename toolchain/check/fuzzer_corpus/{9e2fa6d7320a5b7aa4a136fbc5b9fb9ba6c8d26a => 1c56a65ba702fd27f5a72caf9c5e9170312db350} (81%) rename toolchain/check/fuzzer_corpus/{958211e37b230431232fd97eedce8db62b6c711e => 306f80d197d3d627368e752f1ad6aa42d2e89aa6} (83%) rename toolchain/check/fuzzer_corpus/{5ae87d7a9d55141806809261a2ea9fb567e70aae => 310b6d61f64901b21169432ef6bbc13a2b602376} (92%) rename toolchain/check/fuzzer_corpus/{9369cbcfcb8792587b18645cb5914fa5edeed78d => 48f161ebf1c515fbc92fc959814c40d6394b5360} (91%) rename toolchain/check/fuzzer_corpus/{8670e2da7432feef1ab66b434f95a97fc209b2b0 => 54dab9151ed3293f3aec67e58aa20e26aa632a98} (93%) rename toolchain/check/fuzzer_corpus/{ae7557cf66185fad53df0aa262e52a4dbd8ff8da => b08132223d41827e2b8cd8f849ffb7ac4af4e993} (92%) rename toolchain/check/fuzzer_corpus/{0ca753d0d0e5afc30bc37f855501c9db4776cb5c => b0e276497e7036c6b3c90deeff71a055256ed5e3} (92%) rename toolchain/check/fuzzer_corpus/{530ca26b3435b4490f3e882c3837aef588592497 => bb0ee9a7c7f604c41cfef744a974c6603df4b0db} (91%) rename toolchain/check/fuzzer_corpus/{431077e0b0c67e3442d71fc8dd7b1664c3287b3a => dbd0b78b1bfd4878676ac3d882aee2b797d7af15} (82%) rename toolchain/check/fuzzer_corpus/{9a9abdfff166a4ff4ee660bcce9ec0ba6844d028 => f2b43d44db5dec0cca4bc6fc63f487fabae1b941} (92%) rename toolchain/check/fuzzer_corpus/{45051e270ef1a1b856e7e0a9ad17925204e7efee => f71cbd0475ddb41b78a0d439aa78ae1e2eec0df5} (91%) delete mode 100644 toolchain/check/testdata/array/fail_undefined_bound.carbon rename toolchain/parse/testdata/array/{with_length.carbon => basic.carbon} (62%) delete mode 100644 toolchain/parse/testdata/array/fail_require_close_bracket.carbon delete mode 100644 toolchain/parse/testdata/array/fail_require_semi.carbon delete mode 100644 toolchain/parse/testdata/array/without_length.carbon diff --git a/examples/advent2024/day10_common.carbon b/examples/advent2024/day10_common.carbon index d2c40d9af10c..839965030215 100644 --- a/examples/advent2024/day10_common.carbon +++ b/examples/advent2024/day10_common.carbon @@ -25,5 +25,5 @@ class Terrain { return var; } - var height: [[i32; 43]; 43]; + var height: array(array(i32, 43), 43); } diff --git a/examples/advent2024/day10_part1.carbon b/examples/advent2024/day10_part1.carbon index 33877ade6b6e..a5cf816100de 100644 --- a/examples/advent2024/day10_part1.carbon +++ b/examples/advent2024/day10_part1.carbon @@ -42,7 +42,7 @@ class Reachable { } fn AddLevel[addr self: Self*](terrain: Terrain, level: i32) { - let adj: [(i32, i32); 4] = ((-1, 0), (0, -1), (1, 0), (0, 1)); + let adj: array((i32, i32), 4) = ((-1, 0), (0, -1), (1, 0), (0, 1)); var y: i32 = 0; while (y < 43) { var x: i32 = 0; @@ -84,7 +84,7 @@ class Reachable { return total; } - var trailheads: [[u256; 43]; 43]; + var trailheads: array(array(u256, 43), 43); } fn Run() { diff --git a/examples/advent2024/day10_part2.carbon b/examples/advent2024/day10_part2.carbon index 0ac9731b524d..d4ec248f471d 100644 --- a/examples/advent2024/day10_part2.carbon +++ b/examples/advent2024/day10_part2.carbon @@ -28,7 +28,7 @@ class PathsToTop { fn AddLevel[addr self: Self*](terrain: Terrain, level: i32) -> i64 { var total: i64 = 0; - let adj: [(i32, i32); 4] = ((-1, 0), (0, -1), (1, 0), (0, 1)); + let adj: array((i32, i32), 4) = ((-1, 0), (0, -1), (1, 0), (0, 1)); var y: i32 = 0; while (y < 43) { var x: i32 = 0; @@ -56,7 +56,7 @@ class PathsToTop { return total; } - var paths: [[i64; 43]; 43]; + var paths: array(array(i64, 43), 43); } fn Run() { diff --git a/examples/advent2024/day11_part2.carbon b/examples/advent2024/day11_part2.carbon index ea359d7ecdd0..958eee5840c5 100644 --- a/examples/advent2024/day11_part2.carbon +++ b/examples/advent2024/day11_part2.carbon @@ -41,7 +41,7 @@ class Digits { Core.PrintChar(0x0A); } - var count: [[i64; 75]; 10]; + var count: array(array(i64, 75), 10); } // TODO: Add a builtin to perform integer conversion / truncation. diff --git a/examples/advent2024/day12_common.carbon b/examples/advent2024/day12_common.carbon index e1de4a983664..464d9981886d 100644 --- a/examples/advent2024/day12_common.carbon +++ b/examples/advent2024/day12_common.carbon @@ -31,7 +31,7 @@ class Map { else self.kind[x][y]; } - var kind: [[i32; 140]; 140]; + var kind: array(array(i32, 140), 140); } class DisjointSetForest { @@ -86,7 +86,7 @@ class DisjointSetForest { // TODO: Consider adding ranked choice. // TODO: Make this generic in the payload data. - var nodes: [{.next: i32, .weight: i32, .unions: i32}; 140 * 140]; + var nodes: array({.next: i32, .weight: i32, .unions: i32}, 140 * 140); } fn MakeRegions(map: Map) -> DisjointSetForest { diff --git a/examples/advent2024/day12_part2.carbon b/examples/advent2024/day12_part2.carbon index 0adb06ce8ed9..ddcebcb94d08 100644 --- a/examples/advent2024/day12_part2.carbon +++ b/examples/advent2024/day12_part2.carbon @@ -9,15 +9,15 @@ import Core library "io"; import library "day12_common"; import library "io_utils"; -fn CountExtensions(map: Map, regions: DisjointSetForest*) -> [i32; 140 * 140] { - returned var extensions: [i32; 140 * 140]; +fn CountExtensions(map: Map, regions: DisjointSetForest*) -> array(i32, 140 * 140) { + returned var extensions: array(i32, 140 * 140); var i: i32 = 0; while (i < 140 * 140) { extensions[i] = 0; ++i; } - var ext: [{.same: (i32, i32), .adj: (i32, i32)}; 4] = ( + var ext: array({.same: (i32, i32), .adj: (i32, i32)}, 4) = ( {.same = (-1, 0), .adj = (0, -1)}, {.same = (-1, 0), .adj = (0, 1)}, {.same = (0, -1), .adj = (-1, 0)}, @@ -49,7 +49,7 @@ fn CountExtensions(map: Map, regions: DisjointSetForest*) -> [i32; 140 * 140] { fn Run() { var map: Map = Map.Read(); var regions: DisjointSetForest = MakeRegions(map); - var ext: [i32; 140 * 140] = CountExtensions(map, ®ions); + var ext: array(i32, 140 * 140) = CountExtensions(map, ®ions); var total: i32 = 0; diff --git a/examples/advent2024/day1_common.carbon b/examples/advent2024/day1_common.carbon index 5913081e0c41..db602fe58a0a 100644 --- a/examples/advent2024/day1_common.carbon +++ b/examples/advent2024/day1_common.carbon @@ -10,7 +10,7 @@ import library "io_utils"; // Read a sequence of lines each containing a pair of numbers into two arrays. // Returns the number of lines read. -fn ReadInputs(ap: [i32; 1000]*, bp: [i32; 1000]*) -> i32 { +fn ReadInputs(ap: array(i32, 1000)*, bp: array(i32, 1000)*) -> i32 { var n: i32 = 0; var a: i32; var b: i32; diff --git a/examples/advent2024/day1_part1.carbon b/examples/advent2024/day1_part1.carbon index eb1a6ed739ab..9a422a651b6a 100644 --- a/examples/advent2024/day1_part1.carbon +++ b/examples/advent2024/day1_part1.carbon @@ -12,8 +12,8 @@ import library "sort"; fn Abs(n: i32) -> i32 { return if n < 0 then -n else n; } fn Run() { - var a: [i32; 1000]; - var b: [i32; 1000]; + var a: array(i32, 1000); + var b: array(i32, 1000); var n: i32 = ReadInputs(&a, &b); Quicksort(&a, 0, n); Quicksort(&b, 0, n); diff --git a/examples/advent2024/day1_part2.carbon b/examples/advent2024/day1_part2.carbon index 65b98a6b37ad..c725ffc818fb 100644 --- a/examples/advent2024/day1_part2.carbon +++ b/examples/advent2024/day1_part2.carbon @@ -10,8 +10,8 @@ import library "day1_common"; import library "sort"; fn Run() { - var a: [i32; 1000]; - var b: [i32; 1000]; + var a: array(i32, 1000); + var b: array(i32, 1000); var n: i32 = ReadInputs(&a, &b); Quicksort(&a, 0, n); Quicksort(&b, 0, n); diff --git a/examples/advent2024/day2_part2.carbon b/examples/advent2024/day2_part2.carbon index e085e655c32f..9559c79595e7 100644 --- a/examples/advent2024/day2_part2.carbon +++ b/examples/advent2024/day2_part2.carbon @@ -19,7 +19,7 @@ class Window { ++self->size; } - var data: [i32; 3]; + var data: array(i32, 3); var size: i32; } diff --git a/examples/advent2024/day4_common.carbon b/examples/advent2024/day4_common.carbon index 9f42bd129f3e..f734b4821b0a 100644 --- a/examples/advent2024/day4_common.carbon +++ b/examples/advent2024/day4_common.carbon @@ -32,7 +32,7 @@ class Wordsearch { } // TODO: Make this generic in the length of the search query. - fn Check4[self: Self](xmas: [i32; 4], x: i32, y: i32, dx: i32, dy: i32) -> bool { + fn Check4[self: Self](xmas: array(i32, 4), x: i32, y: i32, dx: i32, dy: i32) -> bool { var i: i32 = 0; while (i < 4) { if (self.At(x + i * dx, y + i * dy) != xmas[i]) { @@ -43,7 +43,7 @@ class Wordsearch { return true; } - fn Check3[self: Self](mas: [i32; 3], x: i32, y: i32, dx: i32, dy: i32) -> bool { + fn Check3[self: Self](mas: array(i32, 3), x: i32, y: i32, dx: i32, dy: i32) -> bool { var i: i32 = 0; while (i < 3) { if (self.At(x + i * dx, y + i * dy) != mas[i]) { @@ -54,5 +54,5 @@ class Wordsearch { return true; } - var grid: [[i32; 140]; 140]; + var grid: array(array(i32, 140), 140); } diff --git a/examples/advent2024/day4_part1.carbon b/examples/advent2024/day4_part1.carbon index 938f90da0ffd..7bcce71d2fa6 100644 --- a/examples/advent2024/day4_part1.carbon +++ b/examples/advent2024/day4_part1.carbon @@ -11,7 +11,7 @@ import library "io_utils"; fn Run() { var search: Wordsearch = Wordsearch.Read(); - var xmas: [i32; 4] = (0x58, 0x4D, 0x41, 0x53); + var xmas: array(i32, 4) = (0x58, 0x4D, 0x41, 0x53); var found: i32 = 0; // TODO: Use for loops once they're implemented. diff --git a/examples/advent2024/day4_part2.carbon b/examples/advent2024/day4_part2.carbon index 291a5d69cff7..e685434c450d 100644 --- a/examples/advent2024/day4_part2.carbon +++ b/examples/advent2024/day4_part2.carbon @@ -11,7 +11,7 @@ import library "io_utils"; fn Run() { var search: Wordsearch = Wordsearch.Read(); - var mas: [i32; 3] = (0x4D, 0x41, 0x53); + var mas: array(i32, 3) = (0x4D, 0x41, 0x53); var found: i32 = 0; // TODO: Use for loops once they're implemented. diff --git a/examples/advent2024/day5_common.carbon b/examples/advent2024/day5_common.carbon index d468790a9d26..58a26560e4c2 100644 --- a/examples/advent2024/day5_common.carbon +++ b/examples/advent2024/day5_common.carbon @@ -36,7 +36,7 @@ class Rules { return self.disallowed_before[b] & PageMask(a) == 0; } - var disallowed_before: [Core.UInt(100); 100]; + var disallowed_before: array(Core.UInt(100), 100); }; class PageList { @@ -112,6 +112,6 @@ class PageList { return self.pages[self.num_pages / 2]; } - var pages: [i32; 24]; + var pages: array(i32, 24); var num_pages: i32; }; diff --git a/examples/advent2024/day6_common.carbon b/examples/advent2024/day6_common.carbon index eb945d2bcd4b..5da9cb1158c0 100644 --- a/examples/advent2024/day6_common.carbon +++ b/examples/advent2024/day6_common.carbon @@ -104,7 +104,7 @@ class Maze { return total; } - var data: [[i8; 130]; 130]; + var data: array(array(i8, 130), 130); var loc: (i32, i32); var dir: (i32, i32); } diff --git a/examples/advent2024/day7_common.carbon b/examples/advent2024/day7_common.carbon index d457cd5dc1c0..a0dc05f187aa 100644 --- a/examples/advent2024/day7_common.carbon +++ b/examples/advent2024/day7_common.carbon @@ -52,7 +52,7 @@ class Equation { return self.SolveFrom(1, self.operands[0], concat); } - var operands: [i64; 16]; + var operands: array(i64, 16); var num_operands: i32; var result: i64; } diff --git a/examples/advent2024/day8_common.carbon b/examples/advent2024/day8_common.carbon index 308f4743511c..e86918cd9d3e 100644 --- a/examples/advent2024/day8_common.carbon +++ b/examples/advent2024/day8_common.carbon @@ -25,5 +25,5 @@ class Grid { return var; } - var data: [[i32; 50]; 50]; + var data: array(array(i32, 50), 50); } diff --git a/examples/advent2024/day8_part2.carbon b/examples/advent2024/day8_part2.carbon index 2539e8754e82..6ee243c1fc37 100644 --- a/examples/advent2024/day8_part2.carbon +++ b/examples/advent2024/day8_part2.carbon @@ -9,7 +9,7 @@ import Core library "io"; import library "day8_common"; import library "io_utils"; -fn MarkAndCount(marks: [[bool; 50]; 50]*, x: i32, y: i32) -> i32 { +fn MarkAndCount(marks: array(array(bool, 50), 50)*, x: i32, y: i32) -> i32 { if (not (*marks)[x][y]) { (*marks)[x][y] = true; return 1; @@ -17,7 +17,7 @@ fn MarkAndCount(marks: [[bool; 50]; 50]*, x: i32, y: i32) -> i32 { return 0; } -fn MarkAndCountAntinodesFor(grid: Grid, marks: [[bool; 50]; 50]*, ax: i32, ay: i32) -> i32 { +fn MarkAndCountAntinodesFor(grid: Grid, marks: array(array(bool, 50), 50)*, ax: i32, ay: i32) -> i32 { var count: i32 = 0; var by: i32 = 0; while (by < 50) { @@ -44,7 +44,7 @@ fn MarkAndCountAntinodesFor(grid: Grid, marks: [[bool; 50]; 50]*, ax: i32, ay: i return count; } -fn MarkAndCountAntinodes(grid: Grid, marks: [[bool; 50]; 50]*) -> i32 { +fn MarkAndCountAntinodes(grid: Grid, marks: array(array(bool, 50), 50)*) -> i32 { var count: i32 = 0; var y: i32 = 0; while (y < 50) { @@ -61,7 +61,7 @@ fn MarkAndCountAntinodes(grid: Grid, marks: [[bool; 50]; 50]*) -> i32 { } fn Run() { - var marks: [[bool; 50]; 50]; + var marks: array(array(bool, 50), 50); var y: i32 = 0; while (y < 50) { var x: i32 = 0; diff --git a/examples/advent2024/day9_common.carbon b/examples/advent2024/day9_common.carbon index 52cc69abb251..9b66138f5036 100644 --- a/examples/advent2024/day9_common.carbon +++ b/examples/advent2024/day9_common.carbon @@ -116,6 +116,6 @@ class SectorList { return total; } - var data: [i32; 200000]; + var data: array(i32, 200000); var size: i32; } diff --git a/examples/advent2024/sort.carbon b/examples/advent2024/sort.carbon index c0be66c5a5da..990ad91c9a67 100644 --- a/examples/advent2024/sort.carbon +++ b/examples/advent2024/sort.carbon @@ -7,13 +7,13 @@ library "sort"; // TODO: Generalize this for other container types once we implement lowering // for generic functions. -fn Swap(p: [i32; 1000]*, from: i32, to: i32) { +fn Swap(p: array(i32, 1000)*, from: i32, to: i32) { var tmp: i32 = (*p)[from]; (*p)[from] = (*p)[to]; (*p)[to] = tmp; } -fn Partition(p: [i32; 1000]*, from_in: i32, to_in: i32) -> i32 { +fn Partition(p: array(i32, 1000)*, from_in: i32, to_in: i32) -> i32 { var pivot_index: i32 = from_in; var pivot: i32 = (*p)[pivot_index]; var from: i32 = from_in + 1; @@ -35,7 +35,7 @@ fn Partition(p: [i32; 1000]*, from_in: i32, to_in: i32) -> i32 { return from - 1; } -fn Quicksort(p: [i32; 1000]*, from: i32, to: i32) { +fn Quicksort(p: array(i32, 1000)*, from: i32, to: i32) { if (from + 1 >= to) { return; } var pivot: i32 = Partition(p, from, to); Quicksort(p, from, pivot); diff --git a/examples/sieve.carbon b/examples/sieve.carbon index 9fddf037330b..0753cc604fb0 100644 --- a/examples/sieve.carbon +++ b/examples/sieve.carbon @@ -28,7 +28,7 @@ class Sieve { } } - var is_prime: [bool; 1000]; + var is_prime: array(bool, 1000); } fn Run() -> i32 { diff --git a/toolchain/check/convert.cpp b/toolchain/check/convert.cpp index 8016a5f630b4..e61b06325e0b 100644 --- a/toolchain/check/convert.cpp +++ b/toolchain/check/convert.cpp @@ -935,7 +935,7 @@ static auto PerformBuiltinConversion(Context& context, SemIR::LocId loc_id, } } - // A tuple (T1, T2, ..., Tn) converts to [T; n] if each Ti converts to T. + // A tuple (T1, T2, ..., Tn) converts to array(T, n) if each Ti converts to T. if (auto target_array_type = target_type_inst.TryAs()) { if (auto src_tuple_type = sem_ir.types().TryGetAs(value_type_id)) { diff --git a/toolchain/check/fuzzer_corpus/dd0aadb8d4ae92d3f07fd7f03c9bfcdc88b1f6bc b/toolchain/check/fuzzer_corpus/0444b366b646a800d860d362876dec36afb41e42 similarity index 92% rename from toolchain/check/fuzzer_corpus/dd0aadb8d4ae92d3f07fd7f03c9bfcdc88b1f6bc rename to toolchain/check/fuzzer_corpus/0444b366b646a800d860d362876dec36afb41e42 index 7c15e78de911..65a02ea4906f 100644 --- a/toolchain/check/fuzzer_corpus/dd0aadb8d4ae92d3f07fd7f03c9bfcdc88b1f6bc +++ b/toolchain/check/fuzzer_corpus/0444b366b646a800d860d362876dec36afb41e42 @@ -20,6 +20,6 @@ class A{ fn Main() -> i32 { var a1: A = {.n = 2}; - var a: [A; 2] = ({.n = 1},{.n = 0}); + var a: array(A, 2) = ({.n = 1},{.n = 0}); return 1; } diff --git a/toolchain/check/fuzzer_corpus/0e272375f1c866bb051eab5262ad87da60f5ce8c b/toolchain/check/fuzzer_corpus/17dc6eb1bbb8fd9671f46aa63924cf1a76837a2c similarity index 89% rename from toolchain/check/fuzzer_corpus/0e272375f1c866bb051eab5262ad87da60f5ce8c rename to toolchain/check/fuzzer_corpus/17dc6eb1bbb8fd9671f46aa63924cf1a76837a2c index 9b9750ffebc9..1c46019341d9 100644 --- a/toolchain/check/fuzzer_corpus/0e272375f1c866bb051eab5262ad87da60f5ce8c +++ b/toolchain/check/fuzzer_corpus/17dc6eb1bbb8fd9671f46aa63924cf1a76837a2c @@ -22,11 +22,11 @@ impl i32 as ImplicitAs(A) { } fn Main() -> i32 { - var arr1: [i32; 2] = (1, 2 as A); + var arr1: array(i32, 2) = (1, 2 as A); Print("1: {0}", arr1[0]); Print("2: {0}", arr1[1]); - var arr2: [A; 2] = (3, 4 as A); + var arr2: array(A, 2) = (3, 4 as A); Print("3: {0}", arr2[0].n); Print("4: {0}", arr2[1].n); return 0; diff --git a/toolchain/check/fuzzer_corpus/9e2fa6d7320a5b7aa4a136fbc5b9fb9ba6c8d26a b/toolchain/check/fuzzer_corpus/1c56a65ba702fd27f5a72caf9c5e9170312db350 similarity index 81% rename from toolchain/check/fuzzer_corpus/9e2fa6d7320a5b7aa4a136fbc5b9fb9ba6c8d26a rename to toolchain/check/fuzzer_corpus/1c56a65ba702fd27f5a72caf9c5e9170312db350 index 16a0ede84e1c..c415b6fdb96e 100644 --- a/toolchain/check/fuzzer_corpus/9e2fa6d7320a5b7aa4a136fbc5b9fb9ba6c8d26a +++ b/toolchain/check/fuzzer_corpus/1c56a65ba702fd27f5a72caf9c5e9170312db350 @@ -7,7 +7,7 @@ package ExplorerTest; fn Main() -> i32 { - // CHECK:STDERR: COMPILATION ERROR: fail_size_mismatch.carbon:[[@LINE+1]]: type error in initializer of variable: '(i32, i32, i32)' is not implicitly convertible to '[i32; 2]' - var x: [i32; 2] = (0, 1, 2); + // CHECK:STDERR: COMPILATION ERROR: fail_size_mismatch.carbon:[[@LINE+1]]: type error in initializer of variable: '(i32, i32, i32)' is not implicitly convertible to 'array(i32, 2)' + var x: array(i32, 2) = (0, 1, 2); return x[0]; } diff --git a/toolchain/check/fuzzer_corpus/958211e37b230431232fd97eedce8db62b6c711e b/toolchain/check/fuzzer_corpus/306f80d197d3d627368e752f1ad6aa42d2e89aa6 similarity index 83% rename from toolchain/check/fuzzer_corpus/958211e37b230431232fd97eedce8db62b6c711e rename to toolchain/check/fuzzer_corpus/306f80d197d3d627368e752f1ad6aa42d2e89aa6 index 0dd7ee61d888..35bf5968d278 100644 --- a/toolchain/check/fuzzer_corpus/958211e37b230431232fd97eedce8db62b6c711e +++ b/toolchain/check/fuzzer_corpus/306f80d197d3d627368e752f1ad6aa42d2e89aa6 @@ -8,6 +8,6 @@ package ExplorerTest; fn Main() -> i32 { - var x: [[i32; 3]; 2] = ((0, 1, 2), (3, 4, 5)); + var x: array(array(i32, 3), 2) = ((0, 1, 2), (3, 4, 5)); return x[1][2] - 5; } diff --git a/toolchain/check/fuzzer_corpus/5ae87d7a9d55141806809261a2ea9fb567e70aae b/toolchain/check/fuzzer_corpus/310b6d61f64901b21169432ef6bbc13a2b602376 similarity index 92% rename from toolchain/check/fuzzer_corpus/5ae87d7a9d55141806809261a2ea9fb567e70aae rename to toolchain/check/fuzzer_corpus/310b6d61f64901b21169432ef6bbc13a2b602376 index 3821170619b6..29b3c789f6f8 100644 --- a/toolchain/check/fuzzer_corpus/5ae87d7a9d55141806809261a2ea9fb567e70aae +++ b/toolchain/check/fuzzer_corpus/310b6d61f64901b21169432ef6bbc13a2b602376 @@ -9,6 +9,6 @@ package ExplorerTest; fn Main() -> i32 { var t: auto = (1, 2); - var a: [i32; 2] = t; + var a: array(i32, 2) = t; return a[0] + a[1]; } diff --git a/toolchain/check/fuzzer_corpus/9369cbcfcb8792587b18645cb5914fa5edeed78d b/toolchain/check/fuzzer_corpus/48f161ebf1c515fbc92fc959814c40d6394b5360 similarity index 91% rename from toolchain/check/fuzzer_corpus/9369cbcfcb8792587b18645cb5914fa5edeed78d rename to toolchain/check/fuzzer_corpus/48f161ebf1c515fbc92fc959814c40d6394b5360 index 28b4e51f7d3c..86d13bbdcdc1 100644 --- a/toolchain/check/fuzzer_corpus/9369cbcfcb8792587b18645cb5914fa5edeed78d +++ b/toolchain/check/fuzzer_corpus/48f161ebf1c515fbc92fc959814c40d6394b5360 @@ -8,7 +8,7 @@ package ExplorerTest; fn Main() -> i32 { - var arr: [i32; 2] = (0, 1); + var arr: array(i32, 2) = (0, 1); var x: [i32;] = arr; var index: i32 = 1; x[index] = 0; diff --git a/toolchain/check/fuzzer_corpus/8670e2da7432feef1ab66b434f95a97fc209b2b0 b/toolchain/check/fuzzer_corpus/54dab9151ed3293f3aec67e58aa20e26aa632a98 similarity index 93% rename from toolchain/check/fuzzer_corpus/8670e2da7432feef1ab66b434f95a97fc209b2b0 rename to toolchain/check/fuzzer_corpus/54dab9151ed3293f3aec67e58aa20e26aa632a98 index 3138db86109c..2b0d8cc7f61c 100644 --- a/toolchain/check/fuzzer_corpus/8670e2da7432feef1ab66b434f95a97fc209b2b0 +++ b/toolchain/check/fuzzer_corpus/54dab9151ed3293f3aec67e58aa20e26aa632a98 @@ -7,7 +7,7 @@ package ExplorerTest; fn Main() -> i32 { - var v: [i32; 2]; + var v: array(i32, 2); // CHECK:STDERR: COMPILATION ERROR: fail_array.carbon:[[@LINE+1]]: use of uninitialized variable v return v[0]; } diff --git a/toolchain/check/fuzzer_corpus/ae7557cf66185fad53df0aa262e52a4dbd8ff8da b/toolchain/check/fuzzer_corpus/b08132223d41827e2b8cd8f849ffb7ac4af4e993 similarity index 92% rename from toolchain/check/fuzzer_corpus/ae7557cf66185fad53df0aa262e52a4dbd8ff8da rename to toolchain/check/fuzzer_corpus/b08132223d41827e2b8cd8f849ffb7ac4af4e993 index 46d235406bc8..f77ab56aee24 100644 --- a/toolchain/check/fuzzer_corpus/ae7557cf66185fad53df0aa262e52a4dbd8ff8da +++ b/toolchain/check/fuzzer_corpus/b08132223d41827e2b8cd8f849ffb7ac4af4e993 @@ -8,7 +8,7 @@ package ExplorerTest; fn Main() -> i32 { - var ar: [i32; 4] = (0, 1,2,3); + var ar: array(i32, 4) = (0, 1,2,3); var count : i32 = 0; for( x: i32 in ar){ count = count +1; diff --git a/toolchain/check/fuzzer_corpus/0ca753d0d0e5afc30bc37f855501c9db4776cb5c b/toolchain/check/fuzzer_corpus/b0e276497e7036c6b3c90deeff71a055256ed5e3 similarity index 92% rename from toolchain/check/fuzzer_corpus/0ca753d0d0e5afc30bc37f855501c9db4776cb5c rename to toolchain/check/fuzzer_corpus/b0e276497e7036c6b3c90deeff71a055256ed5e3 index c55c91ede5d1..5516affc5b96 100644 --- a/toolchain/check/fuzzer_corpus/0ca753d0d0e5afc30bc37f855501c9db4776cb5c +++ b/toolchain/check/fuzzer_corpus/b0e276497e7036c6b3c90deeff71a055256ed5e3 @@ -9,7 +9,7 @@ package ExplorerTest; fn Main() -> i32 { - var ar: [i32; 0] = () ; + var ar: array(i32, 0) = () ; var count : i32 = 0; for( x: i32 in ar ){ count = 2; diff --git a/toolchain/check/fuzzer_corpus/530ca26b3435b4490f3e882c3837aef588592497 b/toolchain/check/fuzzer_corpus/bb0ee9a7c7f604c41cfef744a974c6603df4b0db similarity index 91% rename from toolchain/check/fuzzer_corpus/530ca26b3435b4490f3e882c3837aef588592497 rename to toolchain/check/fuzzer_corpus/bb0ee9a7c7f604c41cfef744a974c6603df4b0db index a7d39d8098e1..3f4c8c6a5794 100644 --- a/toolchain/check/fuzzer_corpus/530ca26b3435b4490f3e882c3837aef588592497 +++ b/toolchain/check/fuzzer_corpus/bb0ee9a7c7f604c41cfef744a974c6603df4b0db @@ -7,7 +7,7 @@ package ExplorerTest; fn Main() -> i32 { - var x: [i32; 2] = (0, 1); + var x: array(i32, 2) = (0, 1); // CHECK:STDERR: RUNTIME ERROR: fail_index.carbon:[[@LINE+1]]: index 2 out of range in (0, 1) return x[2]; } diff --git a/toolchain/check/fuzzer_corpus/431077e0b0c67e3442d71fc8dd7b1664c3287b3a b/toolchain/check/fuzzer_corpus/dbd0b78b1bfd4878676ac3d882aee2b797d7af15 similarity index 82% rename from toolchain/check/fuzzer_corpus/431077e0b0c67e3442d71fc8dd7b1664c3287b3a rename to toolchain/check/fuzzer_corpus/dbd0b78b1bfd4878676ac3d882aee2b797d7af15 index 09b7bd6181e3..1b7295c74873 100644 --- a/toolchain/check/fuzzer_corpus/431077e0b0c67e3442d71fc8dd7b1664c3287b3a +++ b/toolchain/check/fuzzer_corpus/dbd0b78b1bfd4878676ac3d882aee2b797d7af15 @@ -22,7 +22,7 @@ class A{ } fn Main() -> i32 { - var a: [A; 2] = ({.n = 6},{.n = 5}); - var b: [[A; 2]; 2] = (({.n = 4},{.n = 3}), ({.n = 2},{.n = 1})); + var a: array(A, 2) = ({.n = 6},{.n = 5}); + var b: array(array(A, 2), 2) = (({.n = 4},{.n = 3}), ({.n = 2},{.n = 1})); return 1; } diff --git a/toolchain/check/fuzzer_corpus/9a9abdfff166a4ff4ee660bcce9ec0ba6844d028 b/toolchain/check/fuzzer_corpus/f2b43d44db5dec0cca4bc6fc63f487fabae1b941 similarity index 92% rename from toolchain/check/fuzzer_corpus/9a9abdfff166a4ff4ee660bcce9ec0ba6844d028 rename to toolchain/check/fuzzer_corpus/f2b43d44db5dec0cca4bc6fc63f487fabae1b941 index 6af810d10f73..5e6bf2db9e89 100644 --- a/toolchain/check/fuzzer_corpus/9a9abdfff166a4ff4ee660bcce9ec0ba6844d028 +++ b/toolchain/check/fuzzer_corpus/f2b43d44db5dec0cca4bc6fc63f487fabae1b941 @@ -8,6 +8,6 @@ package ExplorerTest; fn Main() -> i32 { // CHECK:STDERR: COMPILATION ERROR: fail_negative_size.carbon:[[@LINE+1]]: Array size cannot be negative - var x: [i32; -1] = (); + var x: array(i32, -1) = (); return x[0]; } diff --git a/toolchain/check/fuzzer_corpus/45051e270ef1a1b856e7e0a9ad17925204e7efee b/toolchain/check/fuzzer_corpus/f71cbd0475ddb41b78a0d439aa78ae1e2eec0df5 similarity index 91% rename from toolchain/check/fuzzer_corpus/45051e270ef1a1b856e7e0a9ad17925204e7efee rename to toolchain/check/fuzzer_corpus/f71cbd0475ddb41b78a0d439aa78ae1e2eec0df5 index 23aeaa554576..00f052f3019d 100644 --- a/toolchain/check/fuzzer_corpus/45051e270ef1a1b856e7e0a9ad17925204e7efee +++ b/toolchain/check/fuzzer_corpus/f71cbd0475ddb41b78a0d439aa78ae1e2eec0df5 @@ -11,7 +11,7 @@ package ExplorerTest; fn Main() -> i32 { - var ar: [i32; 4] = (0, 1,2,3); + var ar: array(i32, 4) = (0, 1,2,3); var count : i32 = 0; for( x: i32 in ar){ count = count +x; diff --git a/toolchain/check/handle_array.cpp b/toolchain/check/handle_array.cpp index 943334cd46af..33ad2d2d9378 100644 --- a/toolchain/check/handle_array.cpp +++ b/toolchain/check/handle_array.cpp @@ -11,27 +11,23 @@ namespace Carbon::Check { -auto HandleParseNode(Context& /*context*/, Parse::ArrayExprStartId /*node_id*/) +auto HandleParseNode(Context& /*context*/, + Parse::ArrayExprOpenParenId /*node_id*/) -> bool { + return true; +} + +auto HandleParseNode(Context& /*context*/, + Parse::ArrayExprKeywordId /*node_id*/) -> bool { + return true; +} + +auto HandleParseNode(Context& /*context*/, Parse::ArrayExprCommaId /*node_id*/) -> bool { return true; } -auto HandleParseNode(Context& context, Parse::ArrayExprSemiId node_id) -> bool { - context.node_stack().Push(node_id); - return true; -} - auto HandleParseNode(Context& context, Parse::ArrayExprId node_id) -> bool { - // TODO: Handle array type with undefined bound. - if (context.node_stack() - .PopAndDiscardSoloNodeIdIf()) { - context.node_stack().PopAndIgnore(); - return context.TODO(node_id, "HandleArrayExprWithoutBounds"); - } - auto bound_inst_id = context.node_stack().PopExpr(); - context.node_stack() - .PopAndDiscardSoloNodeId(); auto [element_type_node_id, element_type_inst_id] = context.node_stack().PopExprWithNodeId(); @@ -43,7 +39,7 @@ auto HandleParseNode(Context& context, Parse::ArrayExprId node_id) -> bool { // call to compile-time-only function" error. // // TODO: Should we support runtime-phase bounds in cases such as: - // comptime fn F(n: i32) -> type { return [i32; n]; } + // comptime fn F(n: i32) -> type { return array(i32; n); } if (!context.constant_values().Get(bound_inst_id).is_constant()) { CARBON_DIAGNOSTIC(InvalidArrayExpr, Error, "array bound is not a constant"); context.emitter().Emit(bound_inst_id, InvalidArrayExpr); diff --git a/toolchain/check/node_stack.h b/toolchain/check/node_stack.h index fe05db6d3b07..0dea644ee397 100644 --- a/toolchain/check/node_stack.h +++ b/toolchain/check/node_stack.h @@ -426,7 +426,6 @@ class NodeStack { case Parse::NodeKind::DefaultLibrary: case Parse::NodeKind::LibraryName: return Id::KindFor(); - case Parse::NodeKind::ArrayExprSemi: case Parse::NodeKind::BuiltinName: case Parse::NodeKind::ChoiceIntroducer: case Parse::NodeKind::ClassIntroducer: @@ -452,7 +451,9 @@ class NodeStack { case Parse::NodeKind::AdaptIntroducer: case Parse::NodeKind::AliasInitializer: case Parse::NodeKind::AliasIntroducer: - case Parse::NodeKind::ArrayExprStart: + case Parse::NodeKind::ArrayExprComma: + case Parse::NodeKind::ArrayExprKeyword: + case Parse::NodeKind::ArrayExprOpenParen: case Parse::NodeKind::BaseColon: case Parse::NodeKind::BaseIntroducer: case Parse::NodeKind::BreakStatementStart: diff --git a/toolchain/check/testdata/array/array_in_place.carbon b/toolchain/check/testdata/array/array_in_place.carbon index 01de23daf879..3d469c5671c1 100644 --- a/toolchain/check/testdata/array/array_in_place.carbon +++ b/toolchain/check/testdata/array/array_in_place.carbon @@ -11,7 +11,7 @@ fn F() -> (i32, i32, i32); fn G() { - var v: [(i32, i32, i32); 2] = (F(), F()); + var v: array((i32, i32, i32), 2) = (F(), F()); } // CHECK:STDOUT: --- array_in_place.carbon @@ -74,32 +74,32 @@ fn G() { // CHECK:STDOUT: %.loc14_3.1: %array_type = var_pattern %v.patt // CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %array_type = var v -// CHECK:STDOUT: %F.ref.loc14_34: %F.type = name_ref F, file.%F.decl [concrete = constants.%F] -// CHECK:STDOUT: %.loc14_42.1: ref %tuple.type.189 = splice_block %.loc14_42.2 { -// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc14_42.2: ref %tuple.type.189 = array_index %v.var, %int_0 -// CHECK:STDOUT: } -// CHECK:STDOUT: %F.call.loc14_36: init %tuple.type.189 = call %F.ref.loc14_34() to %.loc14_42.1 // CHECK:STDOUT: %F.ref.loc14_39: %F.type = name_ref F, file.%F.decl [concrete = constants.%F] -// CHECK:STDOUT: %.loc14_42.3: ref %tuple.type.189 = splice_block %.loc14_42.4 { -// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc14_42.4: ref %tuple.type.189 = array_index %v.var, %int_1 +// CHECK:STDOUT: %.loc14_47.1: ref %tuple.type.189 = splice_block %.loc14_47.2 { +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] +// CHECK:STDOUT: %.loc14_47.2: ref %tuple.type.189 = array_index %v.var, %int_0 // CHECK:STDOUT: } -// CHECK:STDOUT: %F.call.loc14_41: init %tuple.type.189 = call %F.ref.loc14_39() to %.loc14_42.3 -// CHECK:STDOUT: %.loc14_42.5: %tuple.type.99b = tuple_literal (%F.call.loc14_36, %F.call.loc14_41) -// CHECK:STDOUT: %.loc14_42.6: init %array_type = array_init (%F.call.loc14_36, %F.call.loc14_41) to %v.var -// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %.loc14_42.5, %.loc14_42.6 +// CHECK:STDOUT: %F.call.loc14_41: init %tuple.type.189 = call %F.ref.loc14_39() to %.loc14_47.1 +// CHECK:STDOUT: %F.ref.loc14_44: %F.type = name_ref F, file.%F.decl [concrete = constants.%F] +// CHECK:STDOUT: %.loc14_47.3: ref %tuple.type.189 = splice_block %.loc14_47.4 { +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %.loc14_47.4: ref %tuple.type.189 = array_index %v.var, %int_1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %F.call.loc14_46: init %tuple.type.189 = call %F.ref.loc14_44() to %.loc14_47.3 +// CHECK:STDOUT: %.loc14_47.5: %tuple.type.99b = tuple_literal (%F.call.loc14_41, %F.call.loc14_46) +// CHECK:STDOUT: %.loc14_47.6: init %array_type = array_init (%F.call.loc14_41, %F.call.loc14_46) to %v.var +// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %.loc14_47.5, %.loc14_47.6 // CHECK:STDOUT: assign %v.var, %.loc14_3.2 -// CHECK:STDOUT: %.loc14_29: type = splice_block %array_type [concrete = constants.%array_type] { -// CHECK:STDOUT: %int_32.loc14_12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc14_12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %.loc14_34: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc14_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc14_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_32.loc14_22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc14_22: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %.loc14_25.1: %tuple.type.ff9 = tuple_literal (%i32.loc14_12, %i32.loc14_17, %i32.loc14_22) +// CHECK:STDOUT: %int_32.loc14_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %.loc14_30.1: %tuple.type.ff9 = tuple_literal (%i32.loc14_17, %i32.loc14_22, %i32.loc14_27) // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc14_25.2: type = converted %.loc14_25.1, constants.%tuple.type.189 [concrete = constants.%tuple.type.189] +// CHECK:STDOUT: %.loc14_30.2: type = converted %.loc14_30.1, constants.%tuple.type.189 [concrete = constants.%tuple.type.189] // CHECK:STDOUT: %array_type: type = array_type %int_2, %tuple.type.189 [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %v: ref %array_type = bind_name v, %v.var diff --git a/toolchain/check/testdata/array/array_vs_tuple.carbon b/toolchain/check/testdata/array/array_vs_tuple.carbon index d2a5ec242e18..1708659da78f 100644 --- a/toolchain/check/testdata/array/array_vs_tuple.carbon +++ b/toolchain/check/testdata/array/array_vs_tuple.carbon @@ -10,7 +10,7 @@ fn G() { // These should have two different constant values. - var a: [i32; 3] = (1, 2, 3); + var a: array(i32, 3) = (1, 2, 3); var b: (i32, i32, i32) = (1, 2, 3); } @@ -74,42 +74,42 @@ fn G() { // CHECK:STDOUT: %.loc13_3.1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %int_1.loc13_22: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_2.loc13_25: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %int_3.loc13_28: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc13_29.1: %tuple.type.37f = tuple_literal (%int_1.loc13_22, %int_2.loc13_25, %int_3.loc13_28) -// CHECK:STDOUT: %impl.elem0.loc13_29.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc13_29.1: = bound_method %int_1.loc13_22, %impl.elem0.loc13_29.1 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc13_29.1: = specific_function %bound_method.loc13_29.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc13_29.1: init %i32 = call %specific_fn.loc13_29.1(%int_1.loc13_22) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc13_29.2: init %i32 = converted %int_1.loc13_22, %int.convert_checked.loc13_29.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %int_1.loc13_27: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2.loc13_30: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int_3.loc13_33: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc13_34.1: %tuple.type.37f = tuple_literal (%int_1.loc13_27, %int_2.loc13_30, %int_3.loc13_33) +// CHECK:STDOUT: %impl.elem0.loc13_34.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc13_34.1: = bound_method %int_1.loc13_27, %impl.elem0.loc13_34.1 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc13_34.1: = specific_function %bound_method.loc13_34.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc13_34.1: init %i32 = call %specific_fn.loc13_34.1(%int_1.loc13_27) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_34.2: init %i32 = converted %int_1.loc13_27, %int.convert_checked.loc13_34.1 [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc13_29.3: ref %i32 = array_index %a.var, %int_0 -// CHECK:STDOUT: %.loc13_29.4: init %i32 = initialize_from %.loc13_29.2 to %.loc13_29.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc13_29.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc13_29.2: = bound_method %int_2.loc13_25, %impl.elem0.loc13_29.2 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc13_29.2: = specific_function %bound_method.loc13_29.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc13_29.2: init %i32 = call %specific_fn.loc13_29.2(%int_2.loc13_25) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_29.5: init %i32 = converted %int_2.loc13_25, %int.convert_checked.loc13_29.2 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int_1.loc13_29: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc13_29.6: ref %i32 = array_index %a.var, %int_1.loc13_29 -// CHECK:STDOUT: %.loc13_29.7: init %i32 = initialize_from %.loc13_29.5 to %.loc13_29.6 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %impl.elem0.loc13_29.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc13_29.3: = bound_method %int_3.loc13_28, %impl.elem0.loc13_29.3 [concrete = constants.%Convert.bound.b30] -// CHECK:STDOUT: %specific_fn.loc13_29.3: = specific_function %bound_method.loc13_29.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc13_29.3: init %i32 = call %specific_fn.loc13_29.3(%int_3.loc13_28) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc13_29.8: init %i32 = converted %int_3.loc13_28, %int.convert_checked.loc13_29.3 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int_2.loc13_29: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc13_29.9: ref %i32 = array_index %a.var, %int_2.loc13_29 -// CHECK:STDOUT: %.loc13_29.10: init %i32 = initialize_from %.loc13_29.8 to %.loc13_29.9 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc13_29.11: init %array_type = array_init (%.loc13_29.4, %.loc13_29.7, %.loc13_29.10) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc13_3.2: init %array_type = converted %.loc13_29.1, %.loc13_29.11 [concrete = constants.%array] +// CHECK:STDOUT: %.loc13_34.3: ref %i32 = array_index %a.var, %int_0 +// CHECK:STDOUT: %.loc13_34.4: init %i32 = initialize_from %.loc13_34.2 to %.loc13_34.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc13_34.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc13_34.2: = bound_method %int_2.loc13_30, %impl.elem0.loc13_34.2 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc13_34.2: = specific_function %bound_method.loc13_34.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc13_34.2: init %i32 = call %specific_fn.loc13_34.2(%int_2.loc13_30) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_34.5: init %i32 = converted %int_2.loc13_30, %int.convert_checked.loc13_34.2 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int_1.loc13_34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc13_34.6: ref %i32 = array_index %a.var, %int_1.loc13_34 +// CHECK:STDOUT: %.loc13_34.7: init %i32 = initialize_from %.loc13_34.5 to %.loc13_34.6 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %impl.elem0.loc13_34.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc13_34.3: = bound_method %int_3.loc13_33, %impl.elem0.loc13_34.3 [concrete = constants.%Convert.bound.b30] +// CHECK:STDOUT: %specific_fn.loc13_34.3: = specific_function %bound_method.loc13_34.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc13_34.3: init %i32 = call %specific_fn.loc13_34.3(%int_3.loc13_33) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc13_34.8: init %i32 = converted %int_3.loc13_33, %int.convert_checked.loc13_34.3 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int_2.loc13_34: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc13_34.9: ref %i32 = array_index %a.var, %int_2.loc13_34 +// CHECK:STDOUT: %.loc13_34.10: init %i32 = initialize_from %.loc13_34.8 to %.loc13_34.9 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc13_34.11: init %array_type = array_init (%.loc13_34.4, %.loc13_34.7, %.loc13_34.10) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc13_3.2: init %array_type = converted %.loc13_34.1, %.loc13_34.11 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc13_3.2 -// CHECK:STDOUT: %.loc13_17: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc13_22: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %int_3.loc13_16: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type: type = array_type %int_3.loc13_16, %i32 [concrete = constants.%array_type] +// CHECK:STDOUT: %int_3.loc13_21: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %int_3.loc13_21, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: name_binding_decl { diff --git a/toolchain/check/testdata/array/assign_return_value.carbon b/toolchain/check/testdata/array/assign_return_value.carbon index 6c3a75b3e681..7a7f6723d6de 100644 --- a/toolchain/check/testdata/array/assign_return_value.carbon +++ b/toolchain/check/testdata/array/assign_return_value.carbon @@ -11,7 +11,7 @@ fn F() -> (i32,) { return (0,); } fn Run() { - var t: [i32; 1] = F(); + var t: array(i32, 1) = F(); } // CHECK:STDOUT: --- assign_return_value.carbon @@ -96,17 +96,17 @@ fn Run() { // CHECK:STDOUT: %t.var: ref %array_type = var t // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F] // CHECK:STDOUT: %F.call: init %tuple.type.a1c = call %F.ref() -// CHECK:STDOUT: %.loc14_23.1: ref %tuple.type.a1c = temporary_storage -// CHECK:STDOUT: %.loc14_23.2: ref %tuple.type.a1c = temporary %.loc14_23.1, %F.call -// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %.loc14_23.2, element0 -// CHECK:STDOUT: %.loc14_23.3: %i32 = bind_value %tuple.elem0 +// CHECK:STDOUT: %.loc14_28.1: ref %tuple.type.a1c = temporary_storage +// CHECK:STDOUT: %.loc14_28.2: ref %tuple.type.a1c = temporary %.loc14_28.1, %F.call +// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %.loc14_28.2, element0 +// CHECK:STDOUT: %.loc14_28.3: %i32 = bind_value %tuple.elem0 // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc14_23.4: ref %i32 = array_index %t.var, %int_0 -// CHECK:STDOUT: %.loc14_23.5: init %i32 = initialize_from %.loc14_23.3 to %.loc14_23.4 -// CHECK:STDOUT: %.loc14_23.6: init %array_type = array_init (%.loc14_23.5) to %t.var -// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %F.call, %.loc14_23.6 +// CHECK:STDOUT: %.loc14_28.4: ref %i32 = array_index %t.var, %int_0 +// CHECK:STDOUT: %.loc14_28.5: init %i32 = initialize_from %.loc14_28.3 to %.loc14_28.4 +// CHECK:STDOUT: %.loc14_28.6: init %array_type = array_init (%.loc14_28.5) to %t.var +// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %F.call, %.loc14_28.6 // CHECK:STDOUT: assign %t.var, %.loc14_3.2 -// CHECK:STDOUT: %.loc14_17: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc14_22: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] diff --git a/toolchain/check/testdata/array/assign_var.carbon b/toolchain/check/testdata/array/assign_var.carbon index 1e3b17c452db..6d255d0f9444 100644 --- a/toolchain/check/testdata/array/assign_var.carbon +++ b/toolchain/check/testdata/array/assign_var.carbon @@ -9,7 +9,7 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/assign_var.carbon var a: (i32, i32, i32) = (1, 2, 3); -var b: [i32; 3] = a; +var b: array(i32, 3) = a; // CHECK:STDOUT: --- assign_var.carbon // CHECK:STDOUT: @@ -80,7 +80,7 @@ var b: [i32; 3] = a; // CHECK:STDOUT: %.loc12_1: %array_type = var_pattern %b.patt // CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %array_type = var b -// CHECK:STDOUT: %.loc12_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc12_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] @@ -121,22 +121,22 @@ var b: [i32; 3] = a; // CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.189 = name_ref a, file.%a // CHECK:STDOUT: %tuple.elem0.loc12: ref %i32 = tuple_access %a.ref, element0 -// CHECK:STDOUT: %.loc12_19.1: %i32 = bind_value %tuple.elem0.loc12 +// CHECK:STDOUT: %.loc12_24.1: %i32 = bind_value %tuple.elem0.loc12 // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc12_19.2: ref %i32 = array_index file.%b.var, %int_0 -// CHECK:STDOUT: %.loc12_19.3: init %i32 = initialize_from %.loc12_19.1 to %.loc12_19.2 +// CHECK:STDOUT: %.loc12_24.2: ref %i32 = array_index file.%b.var, %int_0 +// CHECK:STDOUT: %.loc12_24.3: init %i32 = initialize_from %.loc12_24.1 to %.loc12_24.2 // CHECK:STDOUT: %tuple.elem1.loc12: ref %i32 = tuple_access %a.ref, element1 -// CHECK:STDOUT: %.loc12_19.4: %i32 = bind_value %tuple.elem1.loc12 +// CHECK:STDOUT: %.loc12_24.4: %i32 = bind_value %tuple.elem1.loc12 // CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc12_19.5: ref %i32 = array_index file.%b.var, %int_1.loc12 -// CHECK:STDOUT: %.loc12_19.6: init %i32 = initialize_from %.loc12_19.4 to %.loc12_19.5 +// CHECK:STDOUT: %.loc12_24.5: ref %i32 = array_index file.%b.var, %int_1.loc12 +// CHECK:STDOUT: %.loc12_24.6: init %i32 = initialize_from %.loc12_24.4 to %.loc12_24.5 // CHECK:STDOUT: %tuple.elem2.loc12: ref %i32 = tuple_access %a.ref, element2 -// CHECK:STDOUT: %.loc12_19.7: %i32 = bind_value %tuple.elem2.loc12 +// CHECK:STDOUT: %.loc12_24.7: %i32 = bind_value %tuple.elem2.loc12 // CHECK:STDOUT: %int_2.loc12: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc12_19.8: ref %i32 = array_index file.%b.var, %int_2.loc12 -// CHECK:STDOUT: %.loc12_19.9: init %i32 = initialize_from %.loc12_19.7 to %.loc12_19.8 -// CHECK:STDOUT: %.loc12_19.10: init %array_type = array_init (%.loc12_19.3, %.loc12_19.6, %.loc12_19.9) to file.%b.var -// CHECK:STDOUT: %.loc12_1: init %array_type = converted %a.ref, %.loc12_19.10 +// CHECK:STDOUT: %.loc12_24.8: ref %i32 = array_index file.%b.var, %int_2.loc12 +// CHECK:STDOUT: %.loc12_24.9: init %i32 = initialize_from %.loc12_24.7 to %.loc12_24.8 +// CHECK:STDOUT: %.loc12_24.10: init %array_type = array_init (%.loc12_24.3, %.loc12_24.6, %.loc12_24.9) to file.%b.var +// CHECK:STDOUT: %.loc12_1: init %array_type = converted %a.ref, %.loc12_24.10 // CHECK:STDOUT: assign file.%b.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/base.carbon b/toolchain/check/testdata/array/base.carbon index e50104610842..edc9fa2ce27b 100644 --- a/toolchain/check/testdata/array/base.carbon +++ b/toolchain/check/testdata/array/base.carbon @@ -8,9 +8,9 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/base.carbon -var a: [i32; 1] = (1,); -var b: [f64; 2] = (11.1, 2.2,); -var c: [(); 5] = ((), (), (), (), (),); +var a: array(i32, 1) = (1,); +var b: array(f64, 2) = (11.1, 2.2,); +var c: array((), 5) = ((), (), (), (), (),); // CHECK:STDOUT: --- base.carbon // CHECK:STDOUT: @@ -74,7 +74,7 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc11_1: %array_type.0cb = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.0cb = var a -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type.loc11 [concrete = constants.%array_type.0cb] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type.loc11 [concrete = constants.%array_type.0cb] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] @@ -86,12 +86,12 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc12_1: %array_type.ce7 = var_pattern %b.patt // CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %array_type.ce7 = var b -// CHECK:STDOUT: %.loc12_15: type = splice_block %array_type.loc12 [concrete = constants.%array_type.ce7] { +// CHECK:STDOUT: %.loc12_20: type = splice_block %array_type.loc12 [concrete = constants.%array_type.ce7] { // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [concrete = f64] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc12_9.1: type = value_of_initializer %float.make_type [concrete = f64] -// CHECK:STDOUT: %.loc12_9.2: type = converted %float.make_type, %.loc12_9.1 [concrete = f64] +// CHECK:STDOUT: %.loc12_14.1: type = value_of_initializer %float.make_type [concrete = f64] +// CHECK:STDOUT: %.loc12_14.2: type = converted %float.make_type, %.loc12_14.1 [concrete = f64] // CHECK:STDOUT: %array_type.loc12: type = array_type %int_2, f64 [concrete = constants.%array_type.ce7] // CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %array_type.ce7 = bind_name b, %b.var @@ -100,10 +100,10 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc13_1: %array_type.c13 = var_pattern %c.patt // CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %array_type.c13 = var c -// CHECK:STDOUT: %.loc13_14: type = splice_block %array_type.loc13 [concrete = constants.%array_type.c13] { -// CHECK:STDOUT: %.loc13_10.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_19: type = splice_block %array_type.loc13 [concrete = constants.%array_type.c13] { +// CHECK:STDOUT: %.loc13_15.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5] -// CHECK:STDOUT: %.loc13_10.2: type = converted %.loc13_10.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc13_15.2: type = converted %.loc13_15.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: %array_type.loc13: type = array_type %int_5, %empty_tuple.type [concrete = constants.%array_type.c13] // CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %array_type.c13 = bind_name c, %c.var @@ -112,58 +112,58 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc11_22.1: %tuple.type.985 = tuple_literal (%int_1.loc11) +// CHECK:STDOUT: %.loc11_27.1: %tuple.type.985 = tuple_literal (%int_1.loc11) // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] // CHECK:STDOUT: %bound_method: = bound_method %int_1.loc11, %impl.elem0 [concrete = constants.%Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_1.loc11) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_22.2: init %i32 = converted %int_1.loc11, %int.convert_checked [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_27.2: init %i32 = converted %int_1.loc11, %int.convert_checked [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0.loc11: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_22.3: ref %i32 = array_index file.%a.var, %int_0.loc11 -// CHECK:STDOUT: %.loc11_22.4: init %i32 = initialize_from %.loc11_22.2 to %.loc11_22.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_22.5: init %array_type.0cb = array_init (%.loc11_22.4) to file.%a.var [concrete = constants.%array.237] -// CHECK:STDOUT: %.loc11_1: init %array_type.0cb = converted %.loc11_22.1, %.loc11_22.5 [concrete = constants.%array.237] +// CHECK:STDOUT: %.loc11_27.3: ref %i32 = array_index file.%a.var, %int_0.loc11 +// CHECK:STDOUT: %.loc11_27.4: init %i32 = initialize_from %.loc11_27.2 to %.loc11_27.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_27.5: init %array_type.0cb = array_init (%.loc11_27.4) to file.%a.var [concrete = constants.%array.237] +// CHECK:STDOUT: %.loc11_1: init %array_type.0cb = converted %.loc11_27.1, %.loc11_27.5 [concrete = constants.%array.237] // CHECK:STDOUT: assign file.%a.var, %.loc11_1 -// CHECK:STDOUT: %float.loc12_20: f64 = float_literal 11.100000000000001 [concrete = constants.%float.6e4] -// CHECK:STDOUT: %float.loc12_26: f64 = float_literal 2.2000000000000002 [concrete = constants.%float.9f7] -// CHECK:STDOUT: %.loc12_30.1: %tuple.type.bdb = tuple_literal (%float.loc12_20, %float.loc12_26) +// CHECK:STDOUT: %float.loc12_25: f64 = float_literal 11.100000000000001 [concrete = constants.%float.6e4] +// CHECK:STDOUT: %float.loc12_31: f64 = float_literal 2.2000000000000002 [concrete = constants.%float.9f7] +// CHECK:STDOUT: %.loc12_35.1: %tuple.type.bdb = tuple_literal (%float.loc12_25, %float.loc12_31) // CHECK:STDOUT: %int_0.loc12: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc12_30.2: ref f64 = array_index file.%b.var, %int_0.loc12 -// CHECK:STDOUT: %.loc12_30.3: init f64 = initialize_from %float.loc12_20 to %.loc12_30.2 [concrete = constants.%float.6e4] +// CHECK:STDOUT: %.loc12_35.2: ref f64 = array_index file.%b.var, %int_0.loc12 +// CHECK:STDOUT: %.loc12_35.3: init f64 = initialize_from %float.loc12_25 to %.loc12_35.2 [concrete = constants.%float.6e4] // CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc12_30.4: ref f64 = array_index file.%b.var, %int_1.loc12 -// CHECK:STDOUT: %.loc12_30.5: init f64 = initialize_from %float.loc12_26 to %.loc12_30.4 [concrete = constants.%float.9f7] -// CHECK:STDOUT: %.loc12_30.6: init %array_type.ce7 = array_init (%.loc12_30.3, %.loc12_30.5) to file.%b.var [concrete = constants.%array.6a2] -// CHECK:STDOUT: %.loc12_1: init %array_type.ce7 = converted %.loc12_30.1, %.loc12_30.6 [concrete = constants.%array.6a2] +// CHECK:STDOUT: %.loc12_35.4: ref f64 = array_index file.%b.var, %int_1.loc12 +// CHECK:STDOUT: %.loc12_35.5: init f64 = initialize_from %float.loc12_31 to %.loc12_35.4 [concrete = constants.%float.9f7] +// CHECK:STDOUT: %.loc12_35.6: init %array_type.ce7 = array_init (%.loc12_35.3, %.loc12_35.5) to file.%b.var [concrete = constants.%array.6a2] +// CHECK:STDOUT: %.loc12_1: init %array_type.ce7 = converted %.loc12_35.1, %.loc12_35.6 [concrete = constants.%array.6a2] // CHECK:STDOUT: assign file.%b.var, %.loc12_1 -// CHECK:STDOUT: %.loc13_20.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc13_24.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc13_28.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc13_32.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc13_36.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc13_38.1: %tuple.type.5b2 = tuple_literal (%.loc13_20.1, %.loc13_24.1, %.loc13_28.1, %.loc13_32.1, %.loc13_36.1) +// CHECK:STDOUT: %.loc13_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_29.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_33.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_37.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_41.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_43.1: %tuple.type.5b2 = tuple_literal (%.loc13_25.1, %.loc13_29.1, %.loc13_33.1, %.loc13_37.1, %.loc13_41.1) // CHECK:STDOUT: %int_0.loc13: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc13_38.2: ref %empty_tuple.type = array_index file.%c.var, %int_0.loc13 -// CHECK:STDOUT: %.loc13_20.2: init %empty_tuple.type = tuple_init () to %.loc13_38.2 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_38.3: init %empty_tuple.type = converted %.loc13_20.1, %.loc13_20.2 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.2: ref %empty_tuple.type = array_index file.%c.var, %int_0.loc13 +// CHECK:STDOUT: %.loc13_25.2: init %empty_tuple.type = tuple_init () to %.loc13_43.2 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.3: init %empty_tuple.type = converted %.loc13_25.1, %.loc13_25.2 [concrete = constants.%empty_tuple] // CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc13_38.4: ref %empty_tuple.type = array_index file.%c.var, %int_1.loc13 -// CHECK:STDOUT: %.loc13_24.2: init %empty_tuple.type = tuple_init () to %.loc13_38.4 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_38.5: init %empty_tuple.type = converted %.loc13_24.1, %.loc13_24.2 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.4: ref %empty_tuple.type = array_index file.%c.var, %int_1.loc13 +// CHECK:STDOUT: %.loc13_29.2: init %empty_tuple.type = tuple_init () to %.loc13_43.4 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.5: init %empty_tuple.type = converted %.loc13_29.1, %.loc13_29.2 [concrete = constants.%empty_tuple] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc13_38.6: ref %empty_tuple.type = array_index file.%c.var, %int_2 -// CHECK:STDOUT: %.loc13_28.2: init %empty_tuple.type = tuple_init () to %.loc13_38.6 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_38.7: init %empty_tuple.type = converted %.loc13_28.1, %.loc13_28.2 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.6: ref %empty_tuple.type = array_index file.%c.var, %int_2 +// CHECK:STDOUT: %.loc13_33.2: init %empty_tuple.type = tuple_init () to %.loc13_43.6 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.7: init %empty_tuple.type = converted %.loc13_33.1, %.loc13_33.2 [concrete = constants.%empty_tuple] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] -// CHECK:STDOUT: %.loc13_38.8: ref %empty_tuple.type = array_index file.%c.var, %int_3 -// CHECK:STDOUT: %.loc13_32.2: init %empty_tuple.type = tuple_init () to %.loc13_38.8 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_38.9: init %empty_tuple.type = converted %.loc13_32.1, %.loc13_32.2 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.8: ref %empty_tuple.type = array_index file.%c.var, %int_3 +// CHECK:STDOUT: %.loc13_37.2: init %empty_tuple.type = tuple_init () to %.loc13_43.8 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.9: init %empty_tuple.type = converted %.loc13_37.1, %.loc13_37.2 [concrete = constants.%empty_tuple] // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4] -// CHECK:STDOUT: %.loc13_38.10: ref %empty_tuple.type = array_index file.%c.var, %int_4 -// CHECK:STDOUT: %.loc13_36.2: init %empty_tuple.type = tuple_init () to %.loc13_38.10 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_38.11: init %empty_tuple.type = converted %.loc13_36.1, %.loc13_36.2 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_38.12: init %array_type.c13 = array_init (%.loc13_38.3, %.loc13_38.5, %.loc13_38.7, %.loc13_38.9, %.loc13_38.11) to file.%c.var [concrete = constants.%array.1cb] -// CHECK:STDOUT: %.loc13_1: init %array_type.c13 = converted %.loc13_38.1, %.loc13_38.12 [concrete = constants.%array.1cb] +// CHECK:STDOUT: %.loc13_43.10: ref %empty_tuple.type = array_index file.%c.var, %int_4 +// CHECK:STDOUT: %.loc13_41.2: init %empty_tuple.type = tuple_init () to %.loc13_43.10 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.11: init %empty_tuple.type = converted %.loc13_41.1, %.loc13_41.2 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc13_43.12: init %array_type.c13 = array_init (%.loc13_43.3, %.loc13_43.5, %.loc13_43.7, %.loc13_43.9, %.loc13_43.11) to file.%c.var [concrete = constants.%array.1cb] +// CHECK:STDOUT: %.loc13_1: init %array_type.c13 = converted %.loc13_43.1, %.loc13_43.12 [concrete = constants.%array.1cb] // CHECK:STDOUT: assign file.%c.var, %.loc13_1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/canonicalize_index.carbon b/toolchain/check/testdata/array/canonicalize_index.carbon index d72537c39c0d..38a9fb7cc2f3 100644 --- a/toolchain/check/testdata/array/canonicalize_index.carbon +++ b/toolchain/check/testdata/array/canonicalize_index.carbon @@ -11,9 +11,9 @@ fn Add(a: i32, b: i32) -> i32 = "int.sadd"; fn ConvertToU32(a: i32) -> u32 = "int.convert_checked"; -var a: [i32; Add(1, 2)] = (1, 2, 3); -let b: [i32; 3]* = &a; -let c: [i32; ConvertToU32(3)]* = &a; +var a: array(i32, Add(1, 2)) = (1, 2, 3); +let b: array(i32, 3)* = &a; +let c: array(i32, ConvertToU32(3))* = &a; // CHECK:STDOUT: --- canonicalize_index.carbon // CHECK:STDOUT: @@ -135,34 +135,34 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: %.loc14_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc14_23: type = splice_block %array_type.loc14 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc14_28: type = splice_block %array_type.loc14 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %Add.ref: %Add.type.b1f = name_ref Add, %Add.decl [concrete = constants.%Add] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %impl.elem0.loc14_18: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc14_18: = bound_method %int_1, %impl.elem0.loc14_18 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc14_18: = specific_function %bound_method.loc14_18, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc14_18: init %i32 = call %specific_fn.loc14_18(%int_1) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc14_18.1: %i32 = value_of_initializer %int.convert_checked.loc14_18 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc14_18.2: %i32 = converted %int_1, %.loc14_18.1 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc14_21: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc14_21: = bound_method %int_2, %impl.elem0.loc14_21 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc14_21: = specific_function %bound_method.loc14_21, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc14_21: init %i32 = call %specific_fn.loc14_21(%int_2) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc14_21.1: %i32 = value_of_initializer %int.convert_checked.loc14_21 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc14_21.2: %i32 = converted %int_2, %.loc14_21.1 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int.sadd: init %i32 = call %Add.ref(%.loc14_18.2, %.loc14_21.2) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %impl.elem0.loc14_22: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] -// CHECK:STDOUT: %bound_method.loc14_22: = bound_method %int.sadd, %impl.elem0.loc14_22 [concrete = constants.%Convert.bound.2d6] -// CHECK:STDOUT: %specific_fn.loc14_22: = specific_function %bound_method.loc14_22, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.377] -// CHECK:STDOUT: %.loc14_22.1: %i32 = value_of_initializer %int.sadd [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc14_22.2: %i32 = converted %int.sadd, %.loc14_22.1 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int.convert_checked.loc14_22: init Core.IntLiteral = call %specific_fn.loc14_22(%.loc14_22.2) [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc14_22.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc14_22 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc14_22.4: Core.IntLiteral = converted %int.sadd, %.loc14_22.3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type.loc14: type = array_type %.loc14_22.4, %i32 [concrete = constants.%array_type] +// CHECK:STDOUT: %impl.elem0.loc14_23: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc14_23: = bound_method %int_1, %impl.elem0.loc14_23 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc14_23: = specific_function %bound_method.loc14_23, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc14_23: init %i32 = call %specific_fn.loc14_23(%int_1) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_23.1: %i32 = value_of_initializer %int.convert_checked.loc14_23 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_23.2: %i32 = converted %int_1, %.loc14_23.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc14_26: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc14_26: = bound_method %int_2, %impl.elem0.loc14_26 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc14_26: = specific_function %bound_method.loc14_26, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc14_26: init %i32 = call %specific_fn.loc14_26(%int_2) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_26.1: %i32 = value_of_initializer %int.convert_checked.loc14_26 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_26.2: %i32 = converted %int_2, %.loc14_26.1 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int.sadd: init %i32 = call %Add.ref(%.loc14_23.2, %.loc14_26.2) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %impl.elem0.loc14_27: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] +// CHECK:STDOUT: %bound_method.loc14_27: = bound_method %int.sadd, %impl.elem0.loc14_27 [concrete = constants.%Convert.bound.2d6] +// CHECK:STDOUT: %specific_fn.loc14_27: = specific_function %bound_method.loc14_27, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.377] +// CHECK:STDOUT: %.loc14_27.1: %i32 = value_of_initializer %int.sadd [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc14_27.2: %i32 = converted %int.sadd, %.loc14_27.1 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc14_27: init Core.IntLiteral = call %specific_fn.loc14_27(%.loc14_27.2) [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc14_27.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc14_27 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc14_27.4: Core.IntLiteral = converted %int.sadd, %.loc14_27.3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc14: type = array_type %.loc14_27.4, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: name_binding_decl { @@ -179,27 +179,27 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %c.patt: %ptr = binding_pattern c // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc16_30: type = splice_block %ptr.loc16 [concrete = constants.%ptr] { +// CHECK:STDOUT: %.loc16_35: type = splice_block %ptr.loc16 [concrete = constants.%ptr] { // CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %ConvertToU32.ref: %ConvertToU32.type = name_ref ConvertToU32, %ConvertToU32.decl [concrete = constants.%ConvertToU32] // CHECK:STDOUT: %int_3.loc16: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %impl.elem0.loc16_27: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc16_27: = bound_method %int_3.loc16, %impl.elem0.loc16_27 [concrete = constants.%Convert.bound.b30] -// CHECK:STDOUT: %specific_fn.loc16_27: = specific_function %bound_method.loc16_27, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc16_27: init %i32 = call %specific_fn.loc16_27(%int_3.loc16) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc16_27.1: %i32 = value_of_initializer %int.convert_checked.loc16_27 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc16_27.2: %i32 = converted %int_3.loc16, %.loc16_27.1 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int.convert_checked.loc16_28.1: init %u32 = call %ConvertToU32.ref(%.loc16_27.2) [concrete = constants.%int_3.d14] -// CHECK:STDOUT: %impl.elem0.loc16_28: %.88a = impl_witness_access constants.%impl_witness.8da2, element0 [concrete = constants.%Convert.47f] -// CHECK:STDOUT: %bound_method.loc16_28: = bound_method %int.convert_checked.loc16_28.1, %impl.elem0.loc16_28 [concrete = constants.%Convert.bound.258] -// CHECK:STDOUT: %specific_fn.loc16_28: = specific_function %bound_method.loc16_28, @Convert.9(constants.%int_32) [concrete = constants.%Convert.specific_fn.d14] -// CHECK:STDOUT: %.loc16_28.1: %u32 = value_of_initializer %int.convert_checked.loc16_28.1 [concrete = constants.%int_3.d14] -// CHECK:STDOUT: %.loc16_28.2: %u32 = converted %int.convert_checked.loc16_28.1, %.loc16_28.1 [concrete = constants.%int_3.d14] -// CHECK:STDOUT: %int.convert_checked.loc16_28.2: init Core.IntLiteral = call %specific_fn.loc16_28(%.loc16_28.2) [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc16_28.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc16_28.2 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc16_28.4: Core.IntLiteral = converted %int.convert_checked.loc16_28.1, %.loc16_28.3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type.loc16: type = array_type %.loc16_28.4, %i32 [concrete = constants.%array_type] +// CHECK:STDOUT: %impl.elem0.loc16_32: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc16_32: = bound_method %int_3.loc16, %impl.elem0.loc16_32 [concrete = constants.%Convert.bound.b30] +// CHECK:STDOUT: %specific_fn.loc16_32: = specific_function %bound_method.loc16_32, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc16_32: init %i32 = call %specific_fn.loc16_32(%int_3.loc16) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc16_32.1: %i32 = value_of_initializer %int.convert_checked.loc16_32 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc16_32.2: %i32 = converted %int_3.loc16, %.loc16_32.1 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc16_33.1: init %u32 = call %ConvertToU32.ref(%.loc16_32.2) [concrete = constants.%int_3.d14] +// CHECK:STDOUT: %impl.elem0.loc16_33: %.88a = impl_witness_access constants.%impl_witness.8da2, element0 [concrete = constants.%Convert.47f] +// CHECK:STDOUT: %bound_method.loc16_33: = bound_method %int.convert_checked.loc16_33.1, %impl.elem0.loc16_33 [concrete = constants.%Convert.bound.258] +// CHECK:STDOUT: %specific_fn.loc16_33: = specific_function %bound_method.loc16_33, @Convert.9(constants.%int_32) [concrete = constants.%Convert.specific_fn.d14] +// CHECK:STDOUT: %.loc16_33.1: %u32 = value_of_initializer %int.convert_checked.loc16_33.1 [concrete = constants.%int_3.d14] +// CHECK:STDOUT: %.loc16_33.2: %u32 = converted %int.convert_checked.loc16_33.1, %.loc16_33.1 [concrete = constants.%int_3.d14] +// CHECK:STDOUT: %int.convert_checked.loc16_33.2: init Core.IntLiteral = call %specific_fn.loc16_33(%.loc16_33.2) [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc16_33.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc16_33.2 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc16_33.4: Core.IntLiteral = converted %int.convert_checked.loc16_33.1, %.loc16_33.3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc16: type = array_type %.loc16_33.4, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: %ptr.loc16: type = ptr_type %array_type [concrete = constants.%ptr] // CHECK:STDOUT: } // CHECK:STDOUT: %c: %ptr = bind_name c, @__global_init.%addr.loc16 @@ -211,36 +211,36 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %int_1.loc14_28: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_2.loc14_31: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int_1.loc14_33: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2.loc14_36: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc14_35.1: %tuple.type = tuple_literal (%int_1.loc14_28, %int_2.loc14_31, %int_3) -// CHECK:STDOUT: %impl.elem0.loc14_35.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc14_35.1: = bound_method %int_1.loc14_28, %impl.elem0.loc14_35.1 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc14_35.1: = specific_function %bound_method.loc14_35.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc14_35.1: init %i32 = call %specific_fn.loc14_35.1(%int_1.loc14_28) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc14_35.2: init %i32 = converted %int_1.loc14_28, %int.convert_checked.loc14_35.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_40.1: %tuple.type = tuple_literal (%int_1.loc14_33, %int_2.loc14_36, %int_3) +// CHECK:STDOUT: %impl.elem0.loc14_40.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc14_40.1: = bound_method %int_1.loc14_33, %impl.elem0.loc14_40.1 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc14_40.1: = specific_function %bound_method.loc14_40.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc14_40.1: init %i32 = call %specific_fn.loc14_40.1(%int_1.loc14_33) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_40.2: init %i32 = converted %int_1.loc14_33, %int.convert_checked.loc14_40.1 [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc14_35.3: ref %i32 = array_index file.%a.var, %int_0 -// CHECK:STDOUT: %.loc14_35.4: init %i32 = initialize_from %.loc14_35.2 to %.loc14_35.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc14_35.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc14_35.2: = bound_method %int_2.loc14_31, %impl.elem0.loc14_35.2 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc14_35.2: = specific_function %bound_method.loc14_35.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc14_35.2: init %i32 = call %specific_fn.loc14_35.2(%int_2.loc14_31) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc14_35.5: init %i32 = converted %int_2.loc14_31, %int.convert_checked.loc14_35.2 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int_1.loc14_35: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc14_35.6: ref %i32 = array_index file.%a.var, %int_1.loc14_35 -// CHECK:STDOUT: %.loc14_35.7: init %i32 = initialize_from %.loc14_35.5 to %.loc14_35.6 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %impl.elem0.loc14_35.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc14_35.3: = bound_method %int_3, %impl.elem0.loc14_35.3 [concrete = constants.%Convert.bound.b30] -// CHECK:STDOUT: %specific_fn.loc14_35.3: = specific_function %bound_method.loc14_35.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc14_35.3: init %i32 = call %specific_fn.loc14_35.3(%int_3) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc14_35.8: init %i32 = converted %int_3, %int.convert_checked.loc14_35.3 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int_2.loc14_35: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc14_35.9: ref %i32 = array_index file.%a.var, %int_2.loc14_35 -// CHECK:STDOUT: %.loc14_35.10: init %i32 = initialize_from %.loc14_35.8 to %.loc14_35.9 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc14_35.11: init %array_type = array_init (%.loc14_35.4, %.loc14_35.7, %.loc14_35.10) to file.%a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc14_1: init %array_type = converted %.loc14_35.1, %.loc14_35.11 [concrete = constants.%array] +// CHECK:STDOUT: %.loc14_40.3: ref %i32 = array_index file.%a.var, %int_0 +// CHECK:STDOUT: %.loc14_40.4: init %i32 = initialize_from %.loc14_40.2 to %.loc14_40.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc14_40.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc14_40.2: = bound_method %int_2.loc14_36, %impl.elem0.loc14_40.2 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc14_40.2: = specific_function %bound_method.loc14_40.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc14_40.2: init %i32 = call %specific_fn.loc14_40.2(%int_2.loc14_36) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_40.5: init %i32 = converted %int_2.loc14_36, %int.convert_checked.loc14_40.2 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int_1.loc14_40: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc14_40.6: ref %i32 = array_index file.%a.var, %int_1.loc14_40 +// CHECK:STDOUT: %.loc14_40.7: init %i32 = initialize_from %.loc14_40.5 to %.loc14_40.6 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %impl.elem0.loc14_40.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc14_40.3: = bound_method %int_3, %impl.elem0.loc14_40.3 [concrete = constants.%Convert.bound.b30] +// CHECK:STDOUT: %specific_fn.loc14_40.3: = specific_function %bound_method.loc14_40.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc14_40.3: init %i32 = call %specific_fn.loc14_40.3(%int_3) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc14_40.8: init %i32 = converted %int_3, %int.convert_checked.loc14_40.3 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int_2.loc14_40: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc14_40.9: ref %i32 = array_index file.%a.var, %int_2.loc14_40 +// CHECK:STDOUT: %.loc14_40.10: init %i32 = initialize_from %.loc14_40.8 to %.loc14_40.9 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc14_40.11: init %array_type = array_init (%.loc14_40.4, %.loc14_40.7, %.loc14_40.10) to file.%a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc14_1: init %array_type = converted %.loc14_40.1, %.loc14_40.11 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc14_1 // CHECK:STDOUT: %a.ref.loc15: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %addr.loc15: %ptr = addr_of %a.ref.loc15 diff --git a/toolchain/check/testdata/array/fail_bound_negative.carbon b/toolchain/check/testdata/array/fail_bound_negative.carbon index e42cd5acfb5e..456d8df51da8 100644 --- a/toolchain/check/testdata/array/fail_bound_negative.carbon +++ b/toolchain/check/testdata/array/fail_bound_negative.carbon @@ -10,11 +10,11 @@ fn Negate(n: i32) -> i32 = "int.snegate"; -// CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+4]]:14: error: array bound of -1 is negative [ArrayBoundNegative] -// CHECK:STDERR: var a: [i32; Negate(1)]; -// CHECK:STDERR: ^~~~~~~~~ +// CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+4]]:19: error: array bound of -1 is negative [ArrayBoundNegative] +// CHECK:STDERR: var a: array(i32, Negate(1)); +// CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: -var a: [i32; Negate(1)]; +var a: array(i32, Negate(1)); // CHECK:STDOUT: --- fail_bound_negative.carbon // CHECK:STDOUT: @@ -85,27 +85,27 @@ var a: [i32; Negate(1)]; // CHECK:STDOUT: %.loc17_1: = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %.loc17_23: type = splice_block %array_type [concrete = ] { +// CHECK:STDOUT: %.loc17_28: type = splice_block %array_type [concrete = ] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %Negate.ref: %Negate.type.15b = name_ref Negate, %Negate.decl [concrete = constants.%Negate] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc17_21: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc17_21: = bound_method %int_1, %impl.elem0.loc17_21 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc17_21: = specific_function %bound_method.loc17_21, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc17_21: init %i32 = call %specific_fn.loc17_21(%int_1) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc17_21.1: %i32 = value_of_initializer %int.convert_checked.loc17_21 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc17_21.2: %i32 = converted %int_1, %.loc17_21.1 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %int.snegate: init %i32 = call %Negate.ref(%.loc17_21.2) [concrete = constants.%int_-1.251] -// CHECK:STDOUT: %impl.elem0.loc17_22: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] -// CHECK:STDOUT: %bound_method.loc17_22: = bound_method %int.snegate, %impl.elem0.loc17_22 [concrete = constants.%Convert.bound.75d] -// CHECK:STDOUT: %specific_fn.loc17_22: = specific_function %bound_method.loc17_22, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.4af] -// CHECK:STDOUT: %.loc17_22.1: %i32 = value_of_initializer %int.snegate [concrete = constants.%int_-1.251] -// CHECK:STDOUT: %.loc17_22.2: %i32 = converted %int.snegate, %.loc17_22.1 [concrete = constants.%int_-1.251] -// CHECK:STDOUT: %int.convert_checked.loc17_22: init Core.IntLiteral = call %specific_fn.loc17_22(%.loc17_22.2) [concrete = constants.%int_-1.638] -// CHECK:STDOUT: %.loc17_22.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc17_22 [concrete = constants.%int_-1.638] -// CHECK:STDOUT: %.loc17_22.4: Core.IntLiteral = converted %int.snegate, %.loc17_22.3 [concrete = constants.%int_-1.638] -// CHECK:STDOUT: %array_type: type = array_type %.loc17_22.4, %i32 [concrete = ] +// CHECK:STDOUT: %impl.elem0.loc17_26: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc17_26: = bound_method %int_1, %impl.elem0.loc17_26 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc17_26: = specific_function %bound_method.loc17_26, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc17_26: init %i32 = call %specific_fn.loc17_26(%int_1) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc17_26.1: %i32 = value_of_initializer %int.convert_checked.loc17_26 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc17_26.2: %i32 = converted %int_1, %.loc17_26.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %int.snegate: init %i32 = call %Negate.ref(%.loc17_26.2) [concrete = constants.%int_-1.251] +// CHECK:STDOUT: %impl.elem0.loc17_27: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] +// CHECK:STDOUT: %bound_method.loc17_27: = bound_method %int.snegate, %impl.elem0.loc17_27 [concrete = constants.%Convert.bound.75d] +// CHECK:STDOUT: %specific_fn.loc17_27: = specific_function %bound_method.loc17_27, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.4af] +// CHECK:STDOUT: %.loc17_27.1: %i32 = value_of_initializer %int.snegate [concrete = constants.%int_-1.251] +// CHECK:STDOUT: %.loc17_27.2: %i32 = converted %int.snegate, %.loc17_27.1 [concrete = constants.%int_-1.251] +// CHECK:STDOUT: %int.convert_checked.loc17_27: init Core.IntLiteral = call %specific_fn.loc17_27(%.loc17_27.2) [concrete = constants.%int_-1.638] +// CHECK:STDOUT: %.loc17_27.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc17_27 [concrete = constants.%int_-1.638] +// CHECK:STDOUT: %.loc17_27.4: Core.IntLiteral = converted %int.snegate, %.loc17_27.3 [concrete = constants.%int_-1.638] +// CHECK:STDOUT: %array_type: type = array_type %.loc17_27.4, %i32 [concrete = ] // CHECK:STDOUT: } // CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/fail_bound_overflow.carbon b/toolchain/check/testdata/array/fail_bound_overflow.carbon index b4b6334f1306..d13f939b2798 100644 --- a/toolchain/check/testdata/array/fail_bound_overflow.carbon +++ b/toolchain/check/testdata/array/fail_bound_overflow.carbon @@ -8,20 +8,20 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_bound_overflow.carbon -// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:14: error: array bound of 39999999999999999993 is too large [ArrayBoundTooLarge] -// CHECK:STDERR: var a: [i32; 39999999999999999993]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:19: error: array bound of 39999999999999999993 is too large [ArrayBoundTooLarge] +// CHECK:STDERR: var a: array(i32, 39999999999999999993); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var a: [i32; 39999999999999999993]; +var a: array(i32, 39999999999999999993); -// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+7]]:9: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure] -// CHECK:STDERR: var b: [1; 39999999999999999993]; -// CHECK:STDERR: ^ -// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:9: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote] -// CHECK:STDERR: var b: [1; 39999999999999999993]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+7]]:14: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure] +// CHECK:STDERR: var b: array(1, 39999999999999999993); +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: var b: array(1, 39999999999999999993); +// CHECK:STDERR: ^ // CHECK:STDERR: -var b: [1; 39999999999999999993]; +var b: array(1, 39999999999999999993); // CHECK:STDOUT: --- fail_bound_overflow.carbon // CHECK:STDOUT: @@ -53,7 +53,7 @@ var b: [1; 39999999999999999993]; // CHECK:STDOUT: %.loc15_1: = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %.loc15_34: type = splice_block %array_type.loc15 [concrete = ] { +// CHECK:STDOUT: %.loc15_39: type = splice_block %array_type.loc15 [concrete = ] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_39999999999999999993.loc15: Core.IntLiteral = int_value 39999999999999999993 [concrete = constants.%int_39999999999999999993] @@ -65,10 +65,10 @@ var b: [1; 39999999999999999993]; // CHECK:STDOUT: %.loc24_1: = var_pattern %b.patt // CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref = var b -// CHECK:STDOUT: %.loc24_32: type = splice_block %array_type.loc24 [concrete = ] { +// CHECK:STDOUT: %.loc24_37: type = splice_block %array_type.loc24 [concrete = ] { // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] // CHECK:STDOUT: %int_39999999999999999993.loc24: Core.IntLiteral = int_value 39999999999999999993 [concrete = constants.%int_39999999999999999993] -// CHECK:STDOUT: %.loc24_9: type = converted %int_1, [concrete = ] +// CHECK:STDOUT: %.loc24_14: type = converted %int_1, [concrete = ] // CHECK:STDOUT: %array_type.loc24: type = array_type %int_39999999999999999993.loc24, [concrete = ] // CHECK:STDOUT: } // CHECK:STDOUT: %b: = bind_name b, diff --git a/toolchain/check/testdata/array/fail_incomplete_element.carbon b/toolchain/check/testdata/array/fail_incomplete_element.carbon index 41fb1d685b7b..012834259a82 100644 --- a/toolchain/check/testdata/array/fail_incomplete_element.carbon +++ b/toolchain/check/testdata/array/fail_incomplete_element.carbon @@ -11,13 +11,13 @@ class Incomplete; // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+7]]:8: error: binding pattern has incomplete type `[Incomplete; 1]` in name binding declaration [IncompleteTypeInBindingDecl] -// CHECK:STDERR: var a: [Incomplete; 1]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~ +// CHECK:STDERR: var a: array(Incomplete, 1); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere] // CHECK:STDERR: class Incomplete; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var a: [Incomplete; 1]; +var a: array(Incomplete, 1); var p: Incomplete* = &a[0]; @@ -52,7 +52,7 @@ var p: Incomplete* = &a[0]; // CHECK:STDOUT: %.loc20_1: = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %.loc20_22: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc20_27: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] // CHECK:STDOUT: %array_type: type = array_type %int_1, %Incomplete [concrete = constants.%array_type] diff --git a/toolchain/check/testdata/array/fail_invalid_type.carbon b/toolchain/check/testdata/array/fail_invalid_type.carbon index fbdd43780b9e..e5872a18ef46 100644 --- a/toolchain/check/testdata/array/fail_invalid_type.carbon +++ b/toolchain/check/testdata/array/fail_invalid_type.carbon @@ -8,14 +8,14 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_invalid_type.carbon -// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+7]]:9: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure] -// CHECK:STDERR: var a: [1; 1]; -// CHECK:STDERR: ^ -// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+4]]:9: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote] -// CHECK:STDERR: var a: [1; 1]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+7]]:14: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure] +// CHECK:STDERR: var a: array(1, 1); +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+4]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: var a: array(1, 1); +// CHECK:STDERR: ^ // CHECK:STDERR: -var a: [1; 1]; +var a: array(1, 1); // CHECK:STDOUT: --- fail_invalid_type.carbon // CHECK:STDOUT: @@ -42,11 +42,11 @@ var a: [1; 1]; // CHECK:STDOUT: %.loc18_1: = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %.loc18_13: type = splice_block %array_type [concrete = ] { -// CHECK:STDOUT: %int_1.loc18_9: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %int_1.loc18_12: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc18_9: type = converted %int_1.loc18_9, [concrete = ] -// CHECK:STDOUT: %array_type: type = array_type %int_1.loc18_12, [concrete = ] +// CHECK:STDOUT: %.loc18_18: type = splice_block %array_type [concrete = ] { +// CHECK:STDOUT: %int_1.loc18_14: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %int_1.loc18_17: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %.loc18_14: type = converted %int_1.loc18_14, [concrete = ] +// CHECK:STDOUT: %array_type: type = array_type %int_1.loc18_17, [concrete = ] // CHECK:STDOUT: } // CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/fail_out_of_bound.carbon b/toolchain/check/testdata/array/fail_out_of_bound.carbon index 6f066f77a10d..ddb277e90b87 100644 --- a/toolchain/check/testdata/array/fail_out_of_bound.carbon +++ b/toolchain/check/testdata/array/fail_out_of_bound.carbon @@ -8,11 +8,11 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_out_of_bound.carbon -// CHECK:STDERR: fail_out_of_bound.carbon:[[@LINE+4]]:19: error: cannot initialize array of 1 element from 3 initializers [ArrayInitFromLiteralArgCountMismatch] -// CHECK:STDERR: var a: [i32; 1] = (1, 2, 3); -// CHECK:STDERR: ^~~~~~~~~ +// CHECK:STDERR: fail_out_of_bound.carbon:[[@LINE+4]]:24: error: cannot initialize array of 1 element from 3 initializers [ArrayInitFromLiteralArgCountMismatch] +// CHECK:STDERR: var a: array(i32, 1) = (1, 2, 3); +// CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: -var a: [i32; 1] = (1, 2, 3); +var a: array(i32, 1) = (1, 2, 3); // CHECK:STDOUT: --- fail_out_of_bound.carbon // CHECK:STDOUT: @@ -45,7 +45,7 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: %.loc15_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc15_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc15_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] diff --git a/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon b/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon index 99ed6f44a22a..43954fdef4a4 100644 --- a/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon +++ b/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon -var a: [i32; 3] = (1, 2, 3); +var a: array(i32, 3) = (1, 2, 3); // CHECK:STDERR: fail_out_of_bound_non_literal.carbon:[[@LINE+4]]:16: error: array index `3` is past the end of type `[i32; 3]` [ArrayIndexOutOfBounds] // CHECK:STDERR: var b: i32 = a[{.index = 3}.index]; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ @@ -68,7 +68,7 @@ var b: i32 = a[{.index = 3}.index]; // CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] @@ -89,36 +89,36 @@ var b: i32 = a[{.index = 3}.index]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %int_1.loc11_20: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_2.loc11_23: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int_1.loc11_25: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2.loc11_28: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] // CHECK:STDOUT: %int_3.loc11: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc11_27.1: %tuple.type = tuple_literal (%int_1.loc11_20, %int_2.loc11_23, %int_3.loc11) -// CHECK:STDOUT: %impl.elem0.loc11_27.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_27.1: = bound_method %int_1.loc11_20, %impl.elem0.loc11_27.1 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc11_27.1: = specific_function %bound_method.loc11_27.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc11_27.1: init %i32 = call %specific_fn.loc11_27.1(%int_1.loc11_20) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_27.2: init %i32 = converted %int_1.loc11_20, %int.convert_checked.loc11_27.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_32.1: %tuple.type = tuple_literal (%int_1.loc11_25, %int_2.loc11_28, %int_3.loc11) +// CHECK:STDOUT: %impl.elem0.loc11_32.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_32.1: = bound_method %int_1.loc11_25, %impl.elem0.loc11_32.1 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc11_32.1: = specific_function %bound_method.loc11_32.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc11_32.1: init %i32 = call %specific_fn.loc11_32.1(%int_1.loc11_25) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_32.2: init %i32 = converted %int_1.loc11_25, %int.convert_checked.loc11_32.1 [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_27.3: ref %i32 = array_index file.%a.var, %int_0 -// CHECK:STDOUT: %.loc11_27.4: init %i32 = initialize_from %.loc11_27.2 to %.loc11_27.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc11_27.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_27.2: = bound_method %int_2.loc11_23, %impl.elem0.loc11_27.2 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc11_27.2: = specific_function %bound_method.loc11_27.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc11_27.2: init %i32 = call %specific_fn.loc11_27.2(%int_2.loc11_23) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc11_27.5: init %i32 = converted %int_2.loc11_23, %int.convert_checked.loc11_27.2 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int_1.loc11_27: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc11_27.6: ref %i32 = array_index file.%a.var, %int_1.loc11_27 -// CHECK:STDOUT: %.loc11_27.7: init %i32 = initialize_from %.loc11_27.5 to %.loc11_27.6 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %impl.elem0.loc11_27.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_27.3: = bound_method %int_3.loc11, %impl.elem0.loc11_27.3 [concrete = constants.%Convert.bound.b30] -// CHECK:STDOUT: %specific_fn.loc11_27.3: = specific_function %bound_method.loc11_27.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc11_27.3: init %i32 = call %specific_fn.loc11_27.3(%int_3.loc11) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc11_27.8: init %i32 = converted %int_3.loc11, %int.convert_checked.loc11_27.3 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int_2.loc11_27: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc11_27.9: ref %i32 = array_index file.%a.var, %int_2.loc11_27 -// CHECK:STDOUT: %.loc11_27.10: init %i32 = initialize_from %.loc11_27.8 to %.loc11_27.9 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc11_27.11: init %array_type = array_init (%.loc11_27.4, %.loc11_27.7, %.loc11_27.10) to file.%a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_27.1, %.loc11_27.11 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_32.3: ref %i32 = array_index file.%a.var, %int_0 +// CHECK:STDOUT: %.loc11_32.4: init %i32 = initialize_from %.loc11_32.2 to %.loc11_32.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc11_32.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_32.2: = bound_method %int_2.loc11_28, %impl.elem0.loc11_32.2 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc11_32.2: = specific_function %bound_method.loc11_32.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc11_32.2: init %i32 = call %specific_fn.loc11_32.2(%int_2.loc11_28) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc11_32.5: init %i32 = converted %int_2.loc11_28, %int.convert_checked.loc11_32.2 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int_1.loc11_32: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc11_32.6: ref %i32 = array_index file.%a.var, %int_1.loc11_32 +// CHECK:STDOUT: %.loc11_32.7: init %i32 = initialize_from %.loc11_32.5 to %.loc11_32.6 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %impl.elem0.loc11_32.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_32.3: = bound_method %int_3.loc11, %impl.elem0.loc11_32.3 [concrete = constants.%Convert.bound.b30] +// CHECK:STDOUT: %specific_fn.loc11_32.3: = specific_function %bound_method.loc11_32.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc11_32.3: init %i32 = call %specific_fn.loc11_32.3(%int_3.loc11) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc11_32.8: init %i32 = converted %int_3.loc11, %int.convert_checked.loc11_32.3 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int_2.loc11_32: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc11_32.9: ref %i32 = array_index file.%a.var, %int_2.loc11_32 +// CHECK:STDOUT: %.loc11_32.10: init %i32 = initialize_from %.loc11_32.8 to %.loc11_32.9 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc11_32.11: init %array_type = array_init (%.loc11_32.4, %.loc11_32.7, %.loc11_32.10) to file.%a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_32.1, %.loc11_32.11 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %int_3.loc16: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] diff --git a/toolchain/check/testdata/array/fail_type_mismatch.carbon b/toolchain/check/testdata/array/fail_type_mismatch.carbon index 9d59bc3b1443..a556a25cdc4f 100644 --- a/toolchain/check/testdata/array/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/array/fail_type_mismatch.carbon @@ -8,37 +8,37 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_type_mismatch.carbon -// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+7]]:19: error: cannot implicitly convert from `String` to `i32` [ImplicitAsConversionFailure] -// CHECK:STDERR: var a: [i32; 3] = (1, "Hello", "World"); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ -// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:19: note: type `String` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote] -// CHECK:STDERR: var a: [i32; 3] = (1, "Hello", "World"); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+7]]:24: error: cannot implicitly convert from `String` to `i32` [ImplicitAsConversionFailure] +// CHECK:STDERR: var a: array(i32, 3) = (1, "Hello", "World"); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:24: note: type `String` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: var a: array(i32, 3) = (1, "Hello", "World"); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var a: [i32; 3] = (1, "Hello", "World"); +var a: array(i32, 3) = (1, "Hello", "World"); var t1: (i32, String, String); -// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+7]]:19: error: cannot implicitly convert from `String` to `i32` [ImplicitAsConversionFailure] -// CHECK:STDERR: var b: [i32; 3] = t1; -// CHECK:STDERR: ^~ -// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:19: note: type `String` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote] -// CHECK:STDERR: var b: [i32; 3] = t1; -// CHECK:STDERR: ^~ +// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+7]]:24: error: cannot implicitly convert from `String` to `i32` [ImplicitAsConversionFailure] +// CHECK:STDERR: var b: array(i32, 3) = t1; +// CHECK:STDERR: ^~ +// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:24: note: type `String` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: var b: array(i32, 3) = t1; +// CHECK:STDERR: ^~ // CHECK:STDERR: -var b: [i32; 3] = t1; +var b: array(i32, 3) = t1; -// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:19: error: cannot initialize array of 3 elements from 2 initializers [ArrayInitFromLiteralArgCountMismatch] -// CHECK:STDERR: var c: [i32; 3] = (1, 2); -// CHECK:STDERR: ^~~~~~ +// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:24: error: cannot initialize array of 3 elements from 2 initializers [ArrayInitFromLiteralArgCountMismatch] +// CHECK:STDERR: var c: array(i32, 3) = (1, 2); +// CHECK:STDERR: ^~~~~~ // CHECK:STDERR: -var c: [i32; 3] = (1, 2); +var c: array(i32, 3) = (1, 2); var t2: (i32, i32); -// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:19: error: cannot initialize array of 3 elements from tuple with 2 elements [ArrayInitFromExprArgCountMismatch] -// CHECK:STDERR: var d: [i32; 3] = t2; -// CHECK:STDERR: ^~ +// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:24: error: cannot initialize array of 3 elements from tuple with 2 elements [ArrayInitFromExprArgCountMismatch] +// CHECK:STDERR: var d: array(i32, 3) = t2; +// CHECK:STDERR: ^~ // CHECK:STDERR: -var d: [i32; 3] = t2; +var d: array(i32, 3) = t2; // CHECK:STDOUT: --- fail_type_mismatch.carbon // CHECK:STDOUT: @@ -95,7 +95,7 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: %.loc18_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc18_15: type = splice_block %array_type.loc18 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc18_20: type = splice_block %array_type.loc18 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3.loc18: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] @@ -119,7 +119,7 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: %.loc28_1: %array_type = var_pattern %b.patt // CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %array_type = var b -// CHECK:STDOUT: %.loc28_15: type = splice_block %array_type.loc28 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc28_20: type = splice_block %array_type.loc28 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc28: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc28: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3.loc28: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] @@ -131,7 +131,7 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: %.loc34_1: %array_type = var_pattern %c.patt // CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %array_type = var c -// CHECK:STDOUT: %.loc34_15: type = splice_block %array_type.loc34 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc34_20: type = splice_block %array_type.loc34 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc34: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc34: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3.loc34: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] @@ -157,7 +157,7 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: %.loc41_1: %array_type = var_pattern %d.patt // CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %array_type = var d -// CHECK:STDOUT: %.loc41_15: type = splice_block %array_type.loc41 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc41_20: type = splice_block %array_type.loc41 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc41: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc41: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3.loc41: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] @@ -169,27 +169,27 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1.loc18: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %str.loc18_23: String = string_literal "Hello" [concrete = constants.%str.ef1] -// CHECK:STDOUT: %str.loc18_32: String = string_literal "World" [concrete = constants.%str.abb] -// CHECK:STDOUT: %.loc18_39.1: %tuple.type.b0f = tuple_literal (%int_1.loc18, %str.loc18_23, %str.loc18_32) +// CHECK:STDOUT: %str.loc18_28: String = string_literal "Hello" [concrete = constants.%str.ef1] +// CHECK:STDOUT: %str.loc18_37: String = string_literal "World" [concrete = constants.%str.abb] +// CHECK:STDOUT: %.loc18_44.1: %tuple.type.b0f = tuple_literal (%int_1.loc18, %str.loc18_28, %str.loc18_37) // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] // CHECK:STDOUT: %bound_method: = bound_method %int_1.loc18, %impl.elem0 [concrete = constants.%Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_1.loc18) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc18_39.2: init %i32 = converted %int_1.loc18, %int.convert_checked [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc18_44.2: init %i32 = converted %int_1.loc18, %int.convert_checked [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0.loc18: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc18_39.3: ref %i32 = array_index file.%a.var, %int_0.loc18 -// CHECK:STDOUT: %.loc18_39.4: init %i32 = initialize_from %.loc18_39.2 to %.loc18_39.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc18_39.5: %i32 = converted %str.loc18_23, [concrete = ] +// CHECK:STDOUT: %.loc18_44.3: ref %i32 = array_index file.%a.var, %int_0.loc18 +// CHECK:STDOUT: %.loc18_44.4: init %i32 = initialize_from %.loc18_44.2 to %.loc18_44.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc18_44.5: %i32 = converted %str.loc18_28, [concrete = ] // CHECK:STDOUT: assign file.%a.var, // CHECK:STDOUT: %t1.ref: ref %tuple.type.9e7 = name_ref t1, file.%t1 // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %t1.ref, element0 -// CHECK:STDOUT: %.loc28_19.1: %i32 = bind_value %tuple.elem0 +// CHECK:STDOUT: %.loc28_24.1: %i32 = bind_value %tuple.elem0 // CHECK:STDOUT: %int_0.loc28: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc28_19.2: ref %i32 = array_index file.%b.var, %int_0.loc28 -// CHECK:STDOUT: %.loc28_19.3: init %i32 = initialize_from %.loc28_19.1 to %.loc28_19.2 +// CHECK:STDOUT: %.loc28_24.2: ref %i32 = array_index file.%b.var, %int_0.loc28 +// CHECK:STDOUT: %.loc28_24.3: init %i32 = initialize_from %.loc28_24.1 to %.loc28_24.2 // CHECK:STDOUT: %tuple.elem1: ref String = tuple_access %t1.ref, element1 -// CHECK:STDOUT: %.loc28_19.4: %i32 = converted %tuple.elem1, [concrete = ] +// CHECK:STDOUT: %.loc28_24.4: %i32 = converted %tuple.elem1, [concrete = ] // CHECK:STDOUT: assign file.%b.var, // CHECK:STDOUT: %int_1.loc34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] diff --git a/toolchain/check/testdata/array/fail_undefined_bound.carbon b/toolchain/check/testdata/array/fail_undefined_bound.carbon deleted file mode 100644 index 83a0e21e61fb..000000000000 --- a/toolchain/check/testdata/array/fail_undefined_bound.carbon +++ /dev/null @@ -1,23 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/array/fail_undefined_bound.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_undefined_bound.carbon - -// CHECK:STDERR: fail_undefined_bound.carbon:[[@LINE+4]]:8: error: semantics TODO: `HandleArrayExprWithoutBounds` [SemanticsTodo] -// CHECK:STDERR: var a: [i32; ]; -// CHECK:STDERR: ^~~~~~~ -// CHECK:STDERR: -var a: [i32; ]; - -// CHECK:STDOUT: --- fail_undefined_bound.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file {} -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/function_param.carbon b/toolchain/check/testdata/array/function_param.carbon index 5d7f524fc9a0..caad8bcef9e2 100644 --- a/toolchain/check/testdata/array/function_param.carbon +++ b/toolchain/check/testdata/array/function_param.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/function_param.carbon -fn F(arr: [i32; 3], i: i32) -> i32 { +fn F(arr: array(i32, 3), i: i32) -> i32 { return arr[i]; } @@ -74,20 +74,20 @@ fn G() -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param2 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32.loc11_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc11_32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_37: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_37: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %arr.param: %array_type = value_param runtime_param0 -// CHECK:STDOUT: %.loc11_18: type = splice_block %array_type [concrete = constants.%array_type] { -// CHECK:STDOUT: %int_32.loc11_12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc11_12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %.loc11_23: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc11_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] // CHECK:STDOUT: %array_type: type = array_type %int_3, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %arr: %array_type = bind_name arr, %arr.param // CHECK:STDOUT: %i.param: %i32 = value_param runtime_param1 -// CHECK:STDOUT: %.loc11_24: type = splice_block %i32.loc11_24 [concrete = constants.%i32] { -// CHECK:STDOUT: %int_32.loc11_24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc11_24: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %.loc11_29: type = splice_block %i32.loc11_29 [concrete = constants.%i32] { +// CHECK:STDOUT: %int_32.loc11_29: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_29: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: %i: %i32 = bind_name i, %i.param // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param2 diff --git a/toolchain/check/testdata/array/generic_empty.carbon b/toolchain/check/testdata/array/generic_empty.carbon index 507aeec23b09..d92cd3dd0941 100644 --- a/toolchain/check/testdata/array/generic_empty.carbon +++ b/toolchain/check/testdata/array/generic_empty.carbon @@ -10,7 +10,7 @@ fn G(T:! type) { // We can initialize this without knowing T. - var arr: [T; 0] = (); + var arr: array(T, 0) = (); } // CHECK:STDOUT: --- generic_empty.carbon @@ -54,27 +54,27 @@ fn G(T:! type) { // CHECK:STDOUT: %T.patt.loc11_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %array_type.loc13_17.2: type = array_type constants.%int_0, @G.%T.loc11_6.2 (%T) [symbolic = %array_type.loc13_17.2 (constants.%array_type)] -// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type.loc13_17.2 (%array_type) [symbolic = %require_complete (constants.%require_complete)] -// CHECK:STDOUT: %array: @G.%array_type.loc13_17.2 (%array_type) = tuple_value () [symbolic = %array (constants.%array)] +// CHECK:STDOUT: %array_type.loc13_22.2: type = array_type constants.%int_0, @G.%T.loc11_6.2 (%T) [symbolic = %array_type.loc13_22.2 (constants.%array_type)] +// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type.loc13_22.2 (%array_type) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: %array: @G.%array_type.loc13_22.2 (%array_type) = tuple_value () [symbolic = %array (constants.%array)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %arr.patt: @G.%array_type.loc13_17.2 (%array_type) = binding_pattern arr -// CHECK:STDOUT: %.loc13_3.1: @G.%array_type.loc13_17.2 (%array_type) = var_pattern %arr.patt +// CHECK:STDOUT: %arr.patt: @G.%array_type.loc13_22.2 (%array_type) = binding_pattern arr +// CHECK:STDOUT: %.loc13_3.1: @G.%array_type.loc13_22.2 (%array_type) = var_pattern %arr.patt // CHECK:STDOUT: } -// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc13_17.2 (%array_type) = var arr -// CHECK:STDOUT: %.loc13_22.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc13_22.2: init @G.%array_type.loc13_17.2 (%array_type) = array_init () to %arr.var [symbolic = %array (constants.%array)] -// CHECK:STDOUT: %.loc13_3.2: init @G.%array_type.loc13_17.2 (%array_type) = converted %.loc13_22.1, %.loc13_22.2 [symbolic = %array (constants.%array)] +// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc13_22.2 (%array_type) = var arr +// CHECK:STDOUT: %.loc13_27.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_27.2: init @G.%array_type.loc13_22.2 (%array_type) = array_init () to %arr.var [symbolic = %array (constants.%array)] +// CHECK:STDOUT: %.loc13_3.2: init @G.%array_type.loc13_22.2 (%array_type) = converted %.loc13_27.1, %.loc13_27.2 [symbolic = %array (constants.%array)] // CHECK:STDOUT: assign %arr.var, %.loc13_3.2 -// CHECK:STDOUT: %.loc13_17: type = splice_block %array_type.loc13_17.1 [symbolic = %array_type.loc13_17.2 (constants.%array_type)] { +// CHECK:STDOUT: %.loc13_22: type = splice_block %array_type.loc13_22.1 [symbolic = %array_type.loc13_22.2 (constants.%array_type)] { // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %array_type.loc13_17.1: type = array_type %int_0, %T [symbolic = %array_type.loc13_17.2 (constants.%array_type)] +// CHECK:STDOUT: %array_type.loc13_22.1: type = array_type %int_0, %T [symbolic = %array_type.loc13_22.2 (constants.%array_type)] // CHECK:STDOUT: } -// CHECK:STDOUT: %arr: ref @G.%array_type.loc13_17.2 (%array_type) = bind_name arr, %arr.var +// CHECK:STDOUT: %arr: ref @G.%array_type.loc13_22.2 (%array_type) = bind_name arr, %arr.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/import.carbon b/toolchain/check/testdata/array/import.carbon index 8d46270e2243..8e4098390266 100644 --- a/toolchain/check/testdata/array/import.carbon +++ b/toolchain/check/testdata/array/import.carbon @@ -12,7 +12,7 @@ library "[[@TEST_NAME]]"; -fn F() -> [i32; 42]; +fn F() -> array(i32, 42); // --- user.carbon diff --git a/toolchain/check/testdata/array/index_not_literal.carbon b/toolchain/check/testdata/array/index_not_literal.carbon index d5395f44acde..0e3c910d4b02 100644 --- a/toolchain/check/testdata/array/index_not_literal.carbon +++ b/toolchain/check/testdata/array/index_not_literal.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/index_not_literal.carbon -var a: [i32; 3] = (1, 2, 3); +var a: array(i32, 3) = (1, 2, 3); var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: --- index_not_literal.carbon @@ -64,7 +64,7 @@ var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] @@ -85,36 +85,36 @@ var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %int_1.loc11_20: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_2.loc11_23: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int_1.loc11_25: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2.loc11_28: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc11_27.1: %tuple.type = tuple_literal (%int_1.loc11_20, %int_2.loc11_23, %int_3) -// CHECK:STDOUT: %impl.elem0.loc11_27.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_27.1: = bound_method %int_1.loc11_20, %impl.elem0.loc11_27.1 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc11_27.1: = specific_function %bound_method.loc11_27.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc11_27.1: init %i32 = call %specific_fn.loc11_27.1(%int_1.loc11_20) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_27.2: init %i32 = converted %int_1.loc11_20, %int.convert_checked.loc11_27.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_32.1: %tuple.type = tuple_literal (%int_1.loc11_25, %int_2.loc11_28, %int_3) +// CHECK:STDOUT: %impl.elem0.loc11_32.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_32.1: = bound_method %int_1.loc11_25, %impl.elem0.loc11_32.1 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc11_32.1: = specific_function %bound_method.loc11_32.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc11_32.1: init %i32 = call %specific_fn.loc11_32.1(%int_1.loc11_25) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_32.2: init %i32 = converted %int_1.loc11_25, %int.convert_checked.loc11_32.1 [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_27.3: ref %i32 = array_index file.%a.var, %int_0 -// CHECK:STDOUT: %.loc11_27.4: init %i32 = initialize_from %.loc11_27.2 to %.loc11_27.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc11_27.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_27.2: = bound_method %int_2.loc11_23, %impl.elem0.loc11_27.2 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc11_27.2: = specific_function %bound_method.loc11_27.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc11_27.2: init %i32 = call %specific_fn.loc11_27.2(%int_2.loc11_23) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc11_27.5: init %i32 = converted %int_2.loc11_23, %int.convert_checked.loc11_27.2 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int_1.loc11_27: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc11_27.6: ref %i32 = array_index file.%a.var, %int_1.loc11_27 -// CHECK:STDOUT: %.loc11_27.7: init %i32 = initialize_from %.loc11_27.5 to %.loc11_27.6 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %impl.elem0.loc11_27.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_27.3: = bound_method %int_3, %impl.elem0.loc11_27.3 [concrete = constants.%Convert.bound.b30] -// CHECK:STDOUT: %specific_fn.loc11_27.3: = specific_function %bound_method.loc11_27.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc11_27.3: init %i32 = call %specific_fn.loc11_27.3(%int_3) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc11_27.8: init %i32 = converted %int_3, %int.convert_checked.loc11_27.3 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int_2.loc11_27: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc11_27.9: ref %i32 = array_index file.%a.var, %int_2.loc11_27 -// CHECK:STDOUT: %.loc11_27.10: init %i32 = initialize_from %.loc11_27.8 to %.loc11_27.9 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc11_27.11: init %array_type = array_init (%.loc11_27.4, %.loc11_27.7, %.loc11_27.10) to file.%a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_27.1, %.loc11_27.11 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_32.3: ref %i32 = array_index file.%a.var, %int_0 +// CHECK:STDOUT: %.loc11_32.4: init %i32 = initialize_from %.loc11_32.2 to %.loc11_32.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc11_32.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_32.2: = bound_method %int_2.loc11_28, %impl.elem0.loc11_32.2 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc11_32.2: = specific_function %bound_method.loc11_32.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc11_32.2: init %i32 = call %specific_fn.loc11_32.2(%int_2.loc11_28) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc11_32.5: init %i32 = converted %int_2.loc11_28, %int.convert_checked.loc11_32.2 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int_1.loc11_32: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc11_32.6: ref %i32 = array_index file.%a.var, %int_1.loc11_32 +// CHECK:STDOUT: %.loc11_32.7: init %i32 = initialize_from %.loc11_32.5 to %.loc11_32.6 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %impl.elem0.loc11_32.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_32.3: = bound_method %int_3, %impl.elem0.loc11_32.3 [concrete = constants.%Convert.bound.b30] +// CHECK:STDOUT: %specific_fn.loc11_32.3: = specific_function %bound_method.loc11_32.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc11_32.3: init %i32 = call %specific_fn.loc11_32.3(%int_3) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc11_32.8: init %i32 = converted %int_3, %int.convert_checked.loc11_32.3 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int_2.loc11_32: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc11_32.9: ref %i32 = array_index file.%a.var, %int_2.loc11_32 +// CHECK:STDOUT: %.loc11_32.10: init %i32 = initialize_from %.loc11_32.8 to %.loc11_32.9 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc11_32.11: init %array_type = array_init (%.loc11_32.4, %.loc11_32.7, %.loc11_32.10) to file.%a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_32.1, %.loc11_32.11 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %int_2.loc12: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] diff --git a/toolchain/check/testdata/array/init_dependent_bound.carbon b/toolchain/check/testdata/array/init_dependent_bound.carbon index effb6a6937df..07ca418653f3 100644 --- a/toolchain/check/testdata/array/init_dependent_bound.carbon +++ b/toolchain/check/testdata/array/init_dependent_bound.carbon @@ -13,11 +13,11 @@ library "[[@TEST_NAME]]"; fn F(N:! i32) { - // CHECK:STDERR: fail_init_dependent_bound.carbon:[[@LINE+4]]:23: error: cannot initialize array with dependent bound from a list of initializers [ArrayInitDependentBound] - // CHECK:STDERR: var arr: [i32; N] = (1, 2, 3); - // CHECK:STDERR: ^~~~~~~~~ + // CHECK:STDERR: fail_init_dependent_bound.carbon:[[@LINE+4]]:28: error: cannot initialize array with dependent bound from a list of initializers [ArrayInitDependentBound] + // CHECK:STDERR: var arr: array(i32, N) = (1, 2, 3); + // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: - var arr: [i32; N] = (1, 2, 3); + var arr: array(i32, N) = (1, 2, 3); } // --- fail_todo_init_template_dependent_bound.carbon @@ -26,11 +26,11 @@ library "[[@TEST_NAME]]"; // TODO: This should be valid. fn G(template N:! i32) { - // CHECK:STDERR: fail_todo_init_template_dependent_bound.carbon:[[@LINE+4]]:23: error: cannot initialize array with dependent bound from a list of initializers [ArrayInitDependentBound] - // CHECK:STDERR: var arr: [i32; N] = (1, 2, 3); - // CHECK:STDERR: ^~~~~~~~~ + // CHECK:STDERR: fail_todo_init_template_dependent_bound.carbon:[[@LINE+4]]:28: error: cannot initialize array with dependent bound from a list of initializers [ArrayInitDependentBound] + // CHECK:STDERR: var arr: array(i32, N) = (1, 2, 3); + // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: - var arr: [i32; N] = (1, 2, 3); + var arr: array(i32, N) = (1, 2, 3); } fn H() { G(3); } @@ -97,35 +97,35 @@ fn H() { G(3); } // CHECK:STDOUT: !definition: // CHECK:STDOUT: %Convert.bound: = bound_method %N.loc4_6.2, constants.%Convert.960 [symbolic = %Convert.bound (constants.%Convert.bound)] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked.loc9_18.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc4_6.2) [symbolic = %int.convert_checked.loc9_18.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc9_19.2: type = array_type %int.convert_checked.loc9_18.2, %i32 [symbolic = %array_type.loc9_19.2 (constants.%array_type)] -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc9_19.2 (%array_type) [symbolic = %require_complete (constants.%require_complete.9dc)] +// CHECK:STDOUT: %int.convert_checked.loc9_23.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc4_6.2) [symbolic = %int.convert_checked.loc9_23.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc9_24.2: type = array_type %int.convert_checked.loc9_23.2, %i32 [symbolic = %array_type.loc9_24.2 (constants.%array_type)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc9_24.2 (%array_type) [symbolic = %require_complete (constants.%require_complete.9dc)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%N.param_patt: %i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %arr.patt: @F.%array_type.loc9_19.2 (%array_type) = binding_pattern arr -// CHECK:STDOUT: %.loc9_3: @F.%array_type.loc9_19.2 (%array_type) = var_pattern %arr.patt +// CHECK:STDOUT: %arr.patt: @F.%array_type.loc9_24.2 (%array_type) = binding_pattern arr +// CHECK:STDOUT: %.loc9_3: @F.%array_type.loc9_24.2 (%array_type) = var_pattern %arr.patt // CHECK:STDOUT: } -// CHECK:STDOUT: %arr.var: ref @F.%array_type.loc9_19.2 (%array_type) = var arr +// CHECK:STDOUT: %arr.var: ref @F.%array_type.loc9_24.2 (%array_type) = var arr // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] -// CHECK:STDOUT: %.loc9_31: %tuple.type = tuple_literal (%int_1, %int_2, %int_3) +// CHECK:STDOUT: %.loc9_36: %tuple.type = tuple_literal (%int_1, %int_2, %int_3) // CHECK:STDOUT: assign %arr.var, -// CHECK:STDOUT: %.loc9_19: type = splice_block %array_type.loc9_19.1 [symbolic = %array_type.loc9_19.2 (constants.%array_type)] { +// CHECK:STDOUT: %.loc9_24: type = splice_block %array_type.loc9_24.1 [symbolic = %array_type.loc9_24.2 (constants.%array_type)] { // CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc4_6.1 [symbolic = %N.loc4_6.2 (constants.%N.51e)] // CHECK:STDOUT: %impl.elem0: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] // CHECK:STDOUT: %bound_method: = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound)] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked.loc9_18.1: init Core.IntLiteral = call %specific_fn(%N.ref) [symbolic = %int.convert_checked.loc9_18.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc9_18.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc9_18.1 [symbolic = %int.convert_checked.loc9_18.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc9_18.2: Core.IntLiteral = converted %N.ref, %.loc9_18.1 [symbolic = %int.convert_checked.loc9_18.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc9_19.1: type = array_type %.loc9_18.2, %i32 [symbolic = %array_type.loc9_19.2 (constants.%array_type)] +// CHECK:STDOUT: %int.convert_checked.loc9_23.1: init Core.IntLiteral = call %specific_fn(%N.ref) [symbolic = %int.convert_checked.loc9_23.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc9_23.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc9_23.1 [symbolic = %int.convert_checked.loc9_23.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc9_23.2: Core.IntLiteral = converted %N.ref, %.loc9_23.1 [symbolic = %int.convert_checked.loc9_23.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc9_24.1: type = array_type %.loc9_23.2, %i32 [symbolic = %array_type.loc9_24.2 (constants.%array_type)] // CHECK:STDOUT: } -// CHECK:STDOUT: %arr: ref @F.%array_type.loc9_19.2 (%array_type) = bind_name arr, %arr.var +// CHECK:STDOUT: %arr: ref @F.%array_type.loc9_24.2 (%array_type) = bind_name arr, %arr.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -217,35 +217,35 @@ fn H() { G(3); } // CHECK:STDOUT: !definition: // CHECK:STDOUT: %Convert.bound: = bound_method %N.loc5_15.2, constants.%Convert.960 [template = %Convert.bound (constants.%Convert.bound.588)] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.3(constants.%int_32) [template = %Convert.specific_fn (constants.%Convert.specific_fn.18b)] -// CHECK:STDOUT: %int.convert_checked.loc10_18.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc5_15.2) [template = %int.convert_checked.loc10_18.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc10_19.2: type = array_type %int.convert_checked.loc10_18.2, %i32 [template = %array_type.loc10_19.2 (constants.%array_type.b04)] -// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type.loc10_19.2 (%array_type.b04) [template = %require_complete (constants.%require_complete.9dc)] +// CHECK:STDOUT: %int.convert_checked.loc10_23.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc5_15.2) [template = %int.convert_checked.loc10_23.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc10_24.2: type = array_type %int.convert_checked.loc10_23.2, %i32 [template = %array_type.loc10_24.2 (constants.%array_type.b04)] +// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type.loc10_24.2 (%array_type.b04) [template = %require_complete (constants.%require_complete.9dc)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%N.param_patt: %i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %arr.patt: @G.%array_type.loc10_19.2 (%array_type.b04) = binding_pattern arr -// CHECK:STDOUT: %.loc10_3: @G.%array_type.loc10_19.2 (%array_type.b04) = var_pattern %arr.patt +// CHECK:STDOUT: %arr.patt: @G.%array_type.loc10_24.2 (%array_type.b04) = binding_pattern arr +// CHECK:STDOUT: %.loc10_3: @G.%array_type.loc10_24.2 (%array_type.b04) = var_pattern %arr.patt // CHECK:STDOUT: } -// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc10_19.2 (%array_type.b04) = var arr +// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc10_24.2 (%array_type.b04) = var arr // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc10_31: %tuple.type = tuple_literal (%int_1, %int_2, %int_3) +// CHECK:STDOUT: %.loc10_36: %tuple.type = tuple_literal (%int_1, %int_2, %int_3) // CHECK:STDOUT: assign %arr.var, -// CHECK:STDOUT: %.loc10_19: type = splice_block %array_type.loc10_19.1 [template = %array_type.loc10_19.2 (constants.%array_type.b04)] { +// CHECK:STDOUT: %.loc10_24: type = splice_block %array_type.loc10_24.1 [template = %array_type.loc10_24.2 (constants.%array_type.b04)] { // CHECK:STDOUT: %int_32.loc10: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc10: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc5_15.1 [template = %N.loc5_15.2 (constants.%N.51e)] // CHECK:STDOUT: %impl.elem0: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] // CHECK:STDOUT: %bound_method: = bound_method %N.ref, %impl.elem0 [template = %Convert.bound (constants.%Convert.bound.588)] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.3(constants.%int_32) [template = %Convert.specific_fn (constants.%Convert.specific_fn.18b)] -// CHECK:STDOUT: %int.convert_checked.loc10_18.1: init Core.IntLiteral = call %specific_fn(%N.ref) [template = %int.convert_checked.loc10_18.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc10_18.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc10_18.1 [template = %int.convert_checked.loc10_18.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc10_18.2: Core.IntLiteral = converted %N.ref, %.loc10_18.1 [template = %int.convert_checked.loc10_18.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc10_19.1: type = array_type %.loc10_18.2, %i32 [template = %array_type.loc10_19.2 (constants.%array_type.b04)] +// CHECK:STDOUT: %int.convert_checked.loc10_23.1: init Core.IntLiteral = call %specific_fn(%N.ref) [template = %int.convert_checked.loc10_23.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc10_23.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc10_23.1 [template = %int.convert_checked.loc10_23.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc10_23.2: Core.IntLiteral = converted %N.ref, %.loc10_23.1 [template = %int.convert_checked.loc10_23.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc10_24.1: type = array_type %.loc10_23.2, %i32 [template = %array_type.loc10_24.2 (constants.%array_type.b04)] // CHECK:STDOUT: } -// CHECK:STDOUT: %arr: ref @G.%array_type.loc10_19.2 (%array_type.b04) = bind_name arr, %arr.var +// CHECK:STDOUT: %arr: ref @G.%array_type.loc10_24.2 (%array_type.b04) = bind_name arr, %arr.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -277,8 +277,8 @@ fn H() { G(3); } // CHECK:STDOUT: !definition: // CHECK:STDOUT: %Convert.bound => constants.%Convert.bound.2d6 // CHECK:STDOUT: %Convert.specific_fn => constants.%Convert.specific_fn.377 -// CHECK:STDOUT: %int.convert_checked.loc10_18.2 => constants.%int_3.1ba -// CHECK:STDOUT: %array_type.loc10_19.2 => constants.%array_type.3fb +// CHECK:STDOUT: %int.convert_checked.loc10_23.2 => constants.%int_3.1ba +// CHECK:STDOUT: %array_type.loc10_24.2 => constants.%array_type.3fb // CHECK:STDOUT: %require_complete => constants.%complete_type.cbf // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/nine_elements.carbon b/toolchain/check/testdata/array/nine_elements.carbon index ecb804cd10df..c6ae0fa7781e 100644 --- a/toolchain/check/testdata/array/nine_elements.carbon +++ b/toolchain/check/testdata/array/nine_elements.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/nine_elements.carbon -var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9); +var a: array(i32, 9) = (1, 2, 3, 4, 5, 6, 7, 8, 9); // CHECK:STDOUT: --- nine_elements.carbon // CHECK:STDOUT: @@ -84,7 +84,7 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9); // CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9.988] @@ -95,90 +95,90 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %int_1.loc11_20: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_2.loc11_23: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %int_3.loc11_26: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %int_4.loc11_29: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1] -// CHECK:STDOUT: %int_5.loc11_32: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] -// CHECK:STDOUT: %int_6.loc11_35: Core.IntLiteral = int_value 6 [concrete = constants.%int_6.462] -// CHECK:STDOUT: %int_7.loc11_38: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f] -// CHECK:STDOUT: %int_8.loc11_41: Core.IntLiteral = int_value 8 [concrete = constants.%int_8.b85] +// CHECK:STDOUT: %int_1.loc11_25: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2.loc11_28: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int_3.loc11_31: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %int_4.loc11_34: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1] +// CHECK:STDOUT: %int_5.loc11_37: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] +// CHECK:STDOUT: %int_6.loc11_40: Core.IntLiteral = int_value 6 [concrete = constants.%int_6.462] +// CHECK:STDOUT: %int_7.loc11_43: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f] +// CHECK:STDOUT: %int_8.loc11_46: Core.IntLiteral = int_value 8 [concrete = constants.%int_8.b85] // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9.988] -// CHECK:STDOUT: %.loc11_45.1: %tuple.type = tuple_literal (%int_1.loc11_20, %int_2.loc11_23, %int_3.loc11_26, %int_4.loc11_29, %int_5.loc11_32, %int_6.loc11_35, %int_7.loc11_38, %int_8.loc11_41, %int_9) -// CHECK:STDOUT: %impl.elem0.loc11_45.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.1: = bound_method %int_1.loc11_20, %impl.elem0.loc11_45.1 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc11_45.1: = specific_function %bound_method.loc11_45.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc11_45.1: init %i32 = call %specific_fn.loc11_45.1(%int_1.loc11_20) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_45.2: init %i32 = converted %int_1.loc11_20, %int.convert_checked.loc11_45.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_50.1: %tuple.type = tuple_literal (%int_1.loc11_25, %int_2.loc11_28, %int_3.loc11_31, %int_4.loc11_34, %int_5.loc11_37, %int_6.loc11_40, %int_7.loc11_43, %int_8.loc11_46, %int_9) +// CHECK:STDOUT: %impl.elem0.loc11_50.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.1: = bound_method %int_1.loc11_25, %impl.elem0.loc11_50.1 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc11_50.1: = specific_function %bound_method.loc11_50.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc11_50.1: init %i32 = call %specific_fn.loc11_50.1(%int_1.loc11_25) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_50.2: init %i32 = converted %int_1.loc11_25, %int.convert_checked.loc11_50.1 [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_45.3: ref %i32 = array_index file.%a.var, %int_0 -// CHECK:STDOUT: %.loc11_45.4: init %i32 = initialize_from %.loc11_45.2 to %.loc11_45.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc11_45.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.2: = bound_method %int_2.loc11_23, %impl.elem0.loc11_45.2 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc11_45.2: = specific_function %bound_method.loc11_45.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc11_45.2: init %i32 = call %specific_fn.loc11_45.2(%int_2.loc11_23) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc11_45.5: init %i32 = converted %int_2.loc11_23, %int.convert_checked.loc11_45.2 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int_1.loc11_45: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc11_45.6: ref %i32 = array_index file.%a.var, %int_1.loc11_45 -// CHECK:STDOUT: %.loc11_45.7: init %i32 = initialize_from %.loc11_45.5 to %.loc11_45.6 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %impl.elem0.loc11_45.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.3: = bound_method %int_3.loc11_26, %impl.elem0.loc11_45.3 [concrete = constants.%Convert.bound.b30] -// CHECK:STDOUT: %specific_fn.loc11_45.3: = specific_function %bound_method.loc11_45.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc11_45.3: init %i32 = call %specific_fn.loc11_45.3(%int_3.loc11_26) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc11_45.8: init %i32 = converted %int_3.loc11_26, %int.convert_checked.loc11_45.3 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int_2.loc11_45: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc11_45.9: ref %i32 = array_index file.%a.var, %int_2.loc11_45 -// CHECK:STDOUT: %.loc11_45.10: init %i32 = initialize_from %.loc11_45.8 to %.loc11_45.9 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %impl.elem0.loc11_45.4: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.4: = bound_method %int_4.loc11_29, %impl.elem0.loc11_45.4 [concrete = constants.%Convert.bound.ac3] -// CHECK:STDOUT: %specific_fn.loc11_45.4: = specific_function %bound_method.loc11_45.4, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.450] -// CHECK:STDOUT: %int.convert_checked.loc11_45.4: init %i32 = call %specific_fn.loc11_45.4(%int_4.loc11_29) [concrete = constants.%int_4.940] -// CHECK:STDOUT: %.loc11_45.11: init %i32 = converted %int_4.loc11_29, %int.convert_checked.loc11_45.4 [concrete = constants.%int_4.940] -// CHECK:STDOUT: %int_3.loc11_45: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc11_45.12: ref %i32 = array_index file.%a.var, %int_3.loc11_45 -// CHECK:STDOUT: %.loc11_45.13: init %i32 = initialize_from %.loc11_45.11 to %.loc11_45.12 [concrete = constants.%int_4.940] -// CHECK:STDOUT: %impl.elem0.loc11_45.5: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.5: = bound_method %int_5.loc11_32, %impl.elem0.loc11_45.5 [concrete = constants.%Convert.bound.4e6] -// CHECK:STDOUT: %specific_fn.loc11_45.5: = specific_function %bound_method.loc11_45.5, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.ba9] -// CHECK:STDOUT: %int.convert_checked.loc11_45.5: init %i32 = call %specific_fn.loc11_45.5(%int_5.loc11_32) [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc11_45.14: init %i32 = converted %int_5.loc11_32, %int.convert_checked.loc11_45.5 [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %int_4.loc11_45: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1] -// CHECK:STDOUT: %.loc11_45.15: ref %i32 = array_index file.%a.var, %int_4.loc11_45 -// CHECK:STDOUT: %.loc11_45.16: init %i32 = initialize_from %.loc11_45.14 to %.loc11_45.15 [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %impl.elem0.loc11_45.6: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.6: = bound_method %int_6.loc11_35, %impl.elem0.loc11_45.6 [concrete = constants.%Convert.bound.ce9] -// CHECK:STDOUT: %specific_fn.loc11_45.6: = specific_function %bound_method.loc11_45.6, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.631] -// CHECK:STDOUT: %int.convert_checked.loc11_45.6: init %i32 = call %specific_fn.loc11_45.6(%int_6.loc11_35) [concrete = constants.%int_6.e56] -// CHECK:STDOUT: %.loc11_45.17: init %i32 = converted %int_6.loc11_35, %int.convert_checked.loc11_45.6 [concrete = constants.%int_6.e56] -// CHECK:STDOUT: %int_5.loc11_45: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] -// CHECK:STDOUT: %.loc11_45.18: ref %i32 = array_index file.%a.var, %int_5.loc11_45 -// CHECK:STDOUT: %.loc11_45.19: init %i32 = initialize_from %.loc11_45.17 to %.loc11_45.18 [concrete = constants.%int_6.e56] -// CHECK:STDOUT: %impl.elem0.loc11_45.7: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.7: = bound_method %int_7.loc11_38, %impl.elem0.loc11_45.7 [concrete = constants.%Convert.bound.208] -// CHECK:STDOUT: %specific_fn.loc11_45.7: = specific_function %bound_method.loc11_45.7, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.c12] -// CHECK:STDOUT: %int.convert_checked.loc11_45.7: init %i32 = call %specific_fn.loc11_45.7(%int_7.loc11_38) [concrete = constants.%int_7.0b1] -// CHECK:STDOUT: %.loc11_45.20: init %i32 = converted %int_7.loc11_38, %int.convert_checked.loc11_45.7 [concrete = constants.%int_7.0b1] -// CHECK:STDOUT: %int_6.loc11_45: Core.IntLiteral = int_value 6 [concrete = constants.%int_6.462] -// CHECK:STDOUT: %.loc11_45.21: ref %i32 = array_index file.%a.var, %int_6.loc11_45 -// CHECK:STDOUT: %.loc11_45.22: init %i32 = initialize_from %.loc11_45.20 to %.loc11_45.21 [concrete = constants.%int_7.0b1] -// CHECK:STDOUT: %impl.elem0.loc11_45.8: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.8: = bound_method %int_8.loc11_41, %impl.elem0.loc11_45.8 [concrete = constants.%Convert.bound.e09] -// CHECK:STDOUT: %specific_fn.loc11_45.8: = specific_function %bound_method.loc11_45.8, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.e0d] -// CHECK:STDOUT: %int.convert_checked.loc11_45.8: init %i32 = call %specific_fn.loc11_45.8(%int_8.loc11_41) [concrete = constants.%int_8.98c] -// CHECK:STDOUT: %.loc11_45.23: init %i32 = converted %int_8.loc11_41, %int.convert_checked.loc11_45.8 [concrete = constants.%int_8.98c] -// CHECK:STDOUT: %int_7.loc11_45: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f] -// CHECK:STDOUT: %.loc11_45.24: ref %i32 = array_index file.%a.var, %int_7.loc11_45 -// CHECK:STDOUT: %.loc11_45.25: init %i32 = initialize_from %.loc11_45.23 to %.loc11_45.24 [concrete = constants.%int_8.98c] -// CHECK:STDOUT: %impl.elem0.loc11_45.9: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_45.9: = bound_method %int_9, %impl.elem0.loc11_45.9 [concrete = constants.%Convert.bound.9e2] -// CHECK:STDOUT: %specific_fn.loc11_45.9: = specific_function %bound_method.loc11_45.9, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b02] -// CHECK:STDOUT: %int.convert_checked.loc11_45.9: init %i32 = call %specific_fn.loc11_45.9(%int_9) [concrete = constants.%int_9.f88] -// CHECK:STDOUT: %.loc11_45.26: init %i32 = converted %int_9, %int.convert_checked.loc11_45.9 [concrete = constants.%int_9.f88] -// CHECK:STDOUT: %int_8.loc11_45: Core.IntLiteral = int_value 8 [concrete = constants.%int_8.b85] -// CHECK:STDOUT: %.loc11_45.27: ref %i32 = array_index file.%a.var, %int_8.loc11_45 -// CHECK:STDOUT: %.loc11_45.28: init %i32 = initialize_from %.loc11_45.26 to %.loc11_45.27 [concrete = constants.%int_9.f88] -// CHECK:STDOUT: %.loc11_45.29: init %array_type = array_init (%.loc11_45.4, %.loc11_45.7, %.loc11_45.10, %.loc11_45.13, %.loc11_45.16, %.loc11_45.19, %.loc11_45.22, %.loc11_45.25, %.loc11_45.28) to file.%a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_45.1, %.loc11_45.29 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_50.3: ref %i32 = array_index file.%a.var, %int_0 +// CHECK:STDOUT: %.loc11_50.4: init %i32 = initialize_from %.loc11_50.2 to %.loc11_50.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc11_50.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.2: = bound_method %int_2.loc11_28, %impl.elem0.loc11_50.2 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc11_50.2: = specific_function %bound_method.loc11_50.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc11_50.2: init %i32 = call %specific_fn.loc11_50.2(%int_2.loc11_28) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc11_50.5: init %i32 = converted %int_2.loc11_28, %int.convert_checked.loc11_50.2 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int_1.loc11_50: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc11_50.6: ref %i32 = array_index file.%a.var, %int_1.loc11_50 +// CHECK:STDOUT: %.loc11_50.7: init %i32 = initialize_from %.loc11_50.5 to %.loc11_50.6 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %impl.elem0.loc11_50.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.3: = bound_method %int_3.loc11_31, %impl.elem0.loc11_50.3 [concrete = constants.%Convert.bound.b30] +// CHECK:STDOUT: %specific_fn.loc11_50.3: = specific_function %bound_method.loc11_50.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc11_50.3: init %i32 = call %specific_fn.loc11_50.3(%int_3.loc11_31) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc11_50.8: init %i32 = converted %int_3.loc11_31, %int.convert_checked.loc11_50.3 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int_2.loc11_50: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc11_50.9: ref %i32 = array_index file.%a.var, %int_2.loc11_50 +// CHECK:STDOUT: %.loc11_50.10: init %i32 = initialize_from %.loc11_50.8 to %.loc11_50.9 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %impl.elem0.loc11_50.4: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.4: = bound_method %int_4.loc11_34, %impl.elem0.loc11_50.4 [concrete = constants.%Convert.bound.ac3] +// CHECK:STDOUT: %specific_fn.loc11_50.4: = specific_function %bound_method.loc11_50.4, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.450] +// CHECK:STDOUT: %int.convert_checked.loc11_50.4: init %i32 = call %specific_fn.loc11_50.4(%int_4.loc11_34) [concrete = constants.%int_4.940] +// CHECK:STDOUT: %.loc11_50.11: init %i32 = converted %int_4.loc11_34, %int.convert_checked.loc11_50.4 [concrete = constants.%int_4.940] +// CHECK:STDOUT: %int_3.loc11_50: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc11_50.12: ref %i32 = array_index file.%a.var, %int_3.loc11_50 +// CHECK:STDOUT: %.loc11_50.13: init %i32 = initialize_from %.loc11_50.11 to %.loc11_50.12 [concrete = constants.%int_4.940] +// CHECK:STDOUT: %impl.elem0.loc11_50.5: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.5: = bound_method %int_5.loc11_37, %impl.elem0.loc11_50.5 [concrete = constants.%Convert.bound.4e6] +// CHECK:STDOUT: %specific_fn.loc11_50.5: = specific_function %bound_method.loc11_50.5, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.ba9] +// CHECK:STDOUT: %int.convert_checked.loc11_50.5: init %i32 = call %specific_fn.loc11_50.5(%int_5.loc11_37) [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc11_50.14: init %i32 = converted %int_5.loc11_37, %int.convert_checked.loc11_50.5 [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %int_4.loc11_50: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1] +// CHECK:STDOUT: %.loc11_50.15: ref %i32 = array_index file.%a.var, %int_4.loc11_50 +// CHECK:STDOUT: %.loc11_50.16: init %i32 = initialize_from %.loc11_50.14 to %.loc11_50.15 [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %impl.elem0.loc11_50.6: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.6: = bound_method %int_6.loc11_40, %impl.elem0.loc11_50.6 [concrete = constants.%Convert.bound.ce9] +// CHECK:STDOUT: %specific_fn.loc11_50.6: = specific_function %bound_method.loc11_50.6, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.631] +// CHECK:STDOUT: %int.convert_checked.loc11_50.6: init %i32 = call %specific_fn.loc11_50.6(%int_6.loc11_40) [concrete = constants.%int_6.e56] +// CHECK:STDOUT: %.loc11_50.17: init %i32 = converted %int_6.loc11_40, %int.convert_checked.loc11_50.6 [concrete = constants.%int_6.e56] +// CHECK:STDOUT: %int_5.loc11_50: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] +// CHECK:STDOUT: %.loc11_50.18: ref %i32 = array_index file.%a.var, %int_5.loc11_50 +// CHECK:STDOUT: %.loc11_50.19: init %i32 = initialize_from %.loc11_50.17 to %.loc11_50.18 [concrete = constants.%int_6.e56] +// CHECK:STDOUT: %impl.elem0.loc11_50.7: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.7: = bound_method %int_7.loc11_43, %impl.elem0.loc11_50.7 [concrete = constants.%Convert.bound.208] +// CHECK:STDOUT: %specific_fn.loc11_50.7: = specific_function %bound_method.loc11_50.7, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.c12] +// CHECK:STDOUT: %int.convert_checked.loc11_50.7: init %i32 = call %specific_fn.loc11_50.7(%int_7.loc11_43) [concrete = constants.%int_7.0b1] +// CHECK:STDOUT: %.loc11_50.20: init %i32 = converted %int_7.loc11_43, %int.convert_checked.loc11_50.7 [concrete = constants.%int_7.0b1] +// CHECK:STDOUT: %int_6.loc11_50: Core.IntLiteral = int_value 6 [concrete = constants.%int_6.462] +// CHECK:STDOUT: %.loc11_50.21: ref %i32 = array_index file.%a.var, %int_6.loc11_50 +// CHECK:STDOUT: %.loc11_50.22: init %i32 = initialize_from %.loc11_50.20 to %.loc11_50.21 [concrete = constants.%int_7.0b1] +// CHECK:STDOUT: %impl.elem0.loc11_50.8: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.8: = bound_method %int_8.loc11_46, %impl.elem0.loc11_50.8 [concrete = constants.%Convert.bound.e09] +// CHECK:STDOUT: %specific_fn.loc11_50.8: = specific_function %bound_method.loc11_50.8, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.e0d] +// CHECK:STDOUT: %int.convert_checked.loc11_50.8: init %i32 = call %specific_fn.loc11_50.8(%int_8.loc11_46) [concrete = constants.%int_8.98c] +// CHECK:STDOUT: %.loc11_50.23: init %i32 = converted %int_8.loc11_46, %int.convert_checked.loc11_50.8 [concrete = constants.%int_8.98c] +// CHECK:STDOUT: %int_7.loc11_50: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f] +// CHECK:STDOUT: %.loc11_50.24: ref %i32 = array_index file.%a.var, %int_7.loc11_50 +// CHECK:STDOUT: %.loc11_50.25: init %i32 = initialize_from %.loc11_50.23 to %.loc11_50.24 [concrete = constants.%int_8.98c] +// CHECK:STDOUT: %impl.elem0.loc11_50.9: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_50.9: = bound_method %int_9, %impl.elem0.loc11_50.9 [concrete = constants.%Convert.bound.9e2] +// CHECK:STDOUT: %specific_fn.loc11_50.9: = specific_function %bound_method.loc11_50.9, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b02] +// CHECK:STDOUT: %int.convert_checked.loc11_50.9: init %i32 = call %specific_fn.loc11_50.9(%int_9) [concrete = constants.%int_9.f88] +// CHECK:STDOUT: %.loc11_50.26: init %i32 = converted %int_9, %int.convert_checked.loc11_50.9 [concrete = constants.%int_9.f88] +// CHECK:STDOUT: %int_8.loc11_50: Core.IntLiteral = int_value 8 [concrete = constants.%int_8.b85] +// CHECK:STDOUT: %.loc11_50.27: ref %i32 = array_index file.%a.var, %int_8.loc11_50 +// CHECK:STDOUT: %.loc11_50.28: init %i32 = initialize_from %.loc11_50.26 to %.loc11_50.27 [concrete = constants.%int_9.f88] +// CHECK:STDOUT: %.loc11_50.29: init %array_type = array_init (%.loc11_50.4, %.loc11_50.7, %.loc11_50.10, %.loc11_50.13, %.loc11_50.16, %.loc11_50.19, %.loc11_50.22, %.loc11_50.25, %.loc11_50.28) to file.%a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_50.1, %.loc11_50.29 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/basics/numeric_literals.carbon b/toolchain/check/testdata/basics/numeric_literals.carbon index b08417cb8bf3..adbe4bf53568 100644 --- a/toolchain/check/testdata/basics/numeric_literals.carbon +++ b/toolchain/check/testdata/basics/numeric_literals.carbon @@ -11,7 +11,7 @@ fn F() { // 8 and 9 trigger special behavior in APInt when mishandling signed versus // unsigned, so we pay extra attention to those. - var ints: [i32; 6] = ( + var ints: array(i32, 6) = ( 8, 9, 0x8, @@ -19,7 +19,7 @@ fn F() { 2147483647, 0x7FFFFFFF, ); - var floats: [f64; 6] = ( + var floats: array(f64, 6) = ( 0.9, 8.0, 80.0, @@ -163,7 +163,7 @@ fn F() { // CHECK:STDOUT: %.loc21_3.20: init %array_type.d49 = array_init (%.loc21_3.4, %.loc21_3.7, %.loc21_3.10, %.loc21_3.13, %.loc21_3.16, %.loc21_3.19) to %ints.var [concrete = constants.%array.ae2] // CHECK:STDOUT: %.loc14_3.2: init %array_type.d49 = converted %.loc21_3.1, %.loc21_3.20 [concrete = constants.%array.ae2] // CHECK:STDOUT: assign %ints.var, %.loc14_3.2 -// CHECK:STDOUT: %.loc14_20: type = splice_block %array_type.loc14 [concrete = constants.%array_type.d49] { +// CHECK:STDOUT: %.loc14_25: type = splice_block %array_type.loc14 [concrete = constants.%array_type.d49] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_6.loc14: Core.IntLiteral = int_value 6 [concrete = constants.%int_6] @@ -203,12 +203,12 @@ fn F() { // CHECK:STDOUT: %.loc29_3.14: init %array_type.72b = array_init (%.loc29_3.3, %.loc29_3.5, %.loc29_3.7, %.loc29_3.9, %.loc29_3.11, %.loc29_3.13) to %floats.var [concrete = constants.%array.a2f] // CHECK:STDOUT: %.loc22_3.2: init %array_type.72b = converted %.loc29_3.1, %.loc29_3.14 [concrete = constants.%array.a2f] // CHECK:STDOUT: assign %floats.var, %.loc22_3.2 -// CHECK:STDOUT: %.loc22_22: type = splice_block %array_type.loc22 [concrete = constants.%array_type.72b] { +// CHECK:STDOUT: %.loc22_27: type = splice_block %array_type.loc22 [concrete = constants.%array_type.72b] { // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [concrete = f64] // CHECK:STDOUT: %int_6.loc22: Core.IntLiteral = int_value 6 [concrete = constants.%int_6] -// CHECK:STDOUT: %.loc22_16.1: type = value_of_initializer %float.make_type [concrete = f64] -// CHECK:STDOUT: %.loc22_16.2: type = converted %float.make_type, %.loc22_16.1 [concrete = f64] +// CHECK:STDOUT: %.loc22_21.1: type = value_of_initializer %float.make_type [concrete = f64] +// CHECK:STDOUT: %.loc22_21.2: type = converted %float.make_type, %.loc22_21.1 [concrete = f64] // CHECK:STDOUT: %array_type.loc22: type = array_type %int_6.loc22, f64 [concrete = constants.%array_type.72b] // CHECK:STDOUT: } // CHECK:STDOUT: %floats: ref %array_type.72b = bind_name floats, %floats.var diff --git a/toolchain/check/testdata/builtin_conversions/value_with_type_through_access.carbon b/toolchain/check/testdata/builtin_conversions/value_with_type_through_access.carbon index 86fcd7f7b507..6a5cee487233 100644 --- a/toolchain/check/testdata/builtin_conversions/value_with_type_through_access.carbon +++ b/toolchain/check/testdata/builtin_conversions/value_with_type_through_access.carbon @@ -74,27 +74,27 @@ fn G() { library "[[@TEST_NAME]]"; -class HoldsType(T:! [type; 1]) {} +class HoldsType(T:! array(type, 1)) {} // `a` is received as a value, and has a type that requires going through // ArrayIndex. Building the value representation must handle this indirection. -// CHECK:STDERR: fail_todo_array_index.carbon:[[@LINE+4]]:41: error: cannot evaluate type expression [TypeExprEvaluationFailure] -// CHECK:STDERR: fn F[T:! [type; 1]](x: HoldsType(T), a: T[0]) {} -// CHECK:STDERR: ^~~~ +// CHECK:STDERR: fail_todo_array_index.carbon:[[@LINE+4]]:46: error: cannot evaluate type expression [TypeExprEvaluationFailure] +// CHECK:STDERR: fn F[T:! array(type, 1)](x: HoldsType(T), a: T[0]) {} +// CHECK:STDERR: ^~~~ // CHECK:STDERR: -fn F[T:! [type; 1]](x: HoldsType(T), a: T[0]) {} +fn F[T:! array(type, 1)](x: HoldsType(T), a: T[0]) {} class C {} fn G() { // CHECK:STDERR: fail_todo_array_index.carbon:[[@LINE+7]]:11: error: argument for generic parameter is not a compile-time constant [CompTimeArgumentNotConstant] - // CHECK:STDERR: F({} as HoldsType((C, ) as [type; 1]), {}); - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: F({} as HoldsType((C, ) as array(type, 1)), {}); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_array_index.carbon:[[@LINE-16]]:17: note: initializing generic parameter `T` declared here [InitializingGenericParam] - // CHECK:STDERR: class HoldsType(T:! [type; 1]) {} + // CHECK:STDERR: class HoldsType(T:! array(type, 1)) {} // CHECK:STDERR: ^ // CHECK:STDERR: - F({} as HoldsType((C, ) as [type; 1]), {}); + F({} as HoldsType((C, ) as array(type, 1)), {}); } @@ -720,27 +720,27 @@ fn G() { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %T.patt.loc12_6.1: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_6.2 (constants.%T.patt)] // CHECK:STDOUT: %T.param_patt: %array_type = value_param_pattern %T.patt.loc12_6.1, runtime_param [symbolic = %T.patt.loc12_6.2 (constants.%T.patt)] -// CHECK:STDOUT: %x.patt: @F.%HoldsType.loc12_35.2 (%HoldsType) = binding_pattern x -// CHECK:STDOUT: %x.param_patt: @F.%HoldsType.loc12_35.2 (%HoldsType) = value_param_pattern %x.patt, runtime_param0 +// CHECK:STDOUT: %x.patt: @F.%HoldsType.loc12_40.2 (%HoldsType) = binding_pattern x +// CHECK:STDOUT: %x.param_patt: @F.%HoldsType.loc12_40.2 (%HoldsType) = value_param_pattern %x.patt, runtime_param0 // CHECK:STDOUT: %a.patt: = binding_pattern a // CHECK:STDOUT: %a.param_patt: = value_param_pattern %a.patt, runtime_param1 // CHECK:STDOUT: } { // CHECK:STDOUT: %T.param: %array_type = value_param runtime_param -// CHECK:STDOUT: %.loc12_18: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc12_23: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] // CHECK:STDOUT: %array_type: type = array_type %int_1, type [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %T.loc12_6.1: %array_type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc12_6.2 (constants.%T)] -// CHECK:STDOUT: %x.param: @F.%HoldsType.loc12_35.2 (%HoldsType) = value_param runtime_param0 -// CHECK:STDOUT: %.loc12_35: type = splice_block %HoldsType.loc12_35.1 [symbolic = %HoldsType.loc12_35.2 (constants.%HoldsType)] { +// CHECK:STDOUT: %x.param: @F.%HoldsType.loc12_40.2 (%HoldsType) = value_param runtime_param0 +// CHECK:STDOUT: %.loc12_40: type = splice_block %HoldsType.loc12_40.1 [symbolic = %HoldsType.loc12_40.2 (constants.%HoldsType)] { // CHECK:STDOUT: %HoldsType.ref: %HoldsType.type = name_ref HoldsType, file.%HoldsType.decl [concrete = constants.%HoldsType.generic] -// CHECK:STDOUT: %T.ref.loc12_34: %array_type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] -// CHECK:STDOUT: %HoldsType.loc12_35.1: type = class_type @HoldsType, @HoldsType(constants.%T) [symbolic = %HoldsType.loc12_35.2 (constants.%HoldsType)] +// CHECK:STDOUT: %T.ref.loc12_39: %array_type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] +// CHECK:STDOUT: %HoldsType.loc12_40.1: type = class_type @HoldsType, @HoldsType(constants.%T) [symbolic = %HoldsType.loc12_40.2 (constants.%HoldsType)] // CHECK:STDOUT: } -// CHECK:STDOUT: %x: @F.%HoldsType.loc12_35.2 (%HoldsType) = bind_name x, %x.param +// CHECK:STDOUT: %x: @F.%HoldsType.loc12_40.2 (%HoldsType) = bind_name x, %x.param // CHECK:STDOUT: %a.param: = value_param runtime_param1 // CHECK:STDOUT: %.1: = splice_block [concrete = ] { -// CHECK:STDOUT: %T.ref.loc12_41: %array_type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc12_46: %array_type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] @@ -748,11 +748,11 @@ fn G() { // CHECK:STDOUT: %bound_method: = bound_method %int_0, %impl.elem0 [concrete = constants.%Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0) [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc12_43.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc12_43.2: %i32 = converted %int_0, %.loc12_43.1 [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc12_44.1: ref %array_type = value_as_ref %T.ref.loc12_41 -// CHECK:STDOUT: %.loc12_44.2: ref type = array_index %.loc12_44.1, %.loc12_43.2 -// CHECK:STDOUT: %.loc12_44.3: type = bind_value %.loc12_44.2 +// CHECK:STDOUT: %.loc12_48.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc12_48.2: %i32 = converted %int_0, %.loc12_48.1 [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc12_49.1: ref %array_type = value_as_ref %T.ref.loc12_46 +// CHECK:STDOUT: %.loc12_49.2: ref type = array_index %.loc12_49.1, %.loc12_48.2 +// CHECK:STDOUT: %.loc12_49.3: type = bind_value %.loc12_49.2 // CHECK:STDOUT: } // CHECK:STDOUT: %a: = bind_name a, %a.param // CHECK:STDOUT: } @@ -786,12 +786,12 @@ fn G() { // CHECK:STDOUT: generic fn @F(%T.loc12_6.1: %array_type) { // CHECK:STDOUT: %T.loc12_6.2: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc12_6.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc12_6.2: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_6.2 (constants.%T.patt)] -// CHECK:STDOUT: %HoldsType.loc12_35.2: type = class_type @HoldsType, @HoldsType(%T.loc12_6.2) [symbolic = %HoldsType.loc12_35.2 (constants.%HoldsType)] +// CHECK:STDOUT: %HoldsType.loc12_40.2: type = class_type @HoldsType, @HoldsType(%T.loc12_6.2) [symbolic = %HoldsType.loc12_40.2 (constants.%HoldsType)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%HoldsType.loc12_35.2 (%HoldsType) [symbolic = %require_complete (constants.%require_complete.640)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%HoldsType.loc12_40.2 (%HoldsType) [symbolic = %require_complete (constants.%require_complete.640)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%T.param_patt: %array_type](%x.param_patt: @F.%HoldsType.loc12_35.2 (%HoldsType), %a.param_patt: ) { +// CHECK:STDOUT: fn[%T.param_patt: %array_type](%x.param_patt: @F.%HoldsType.loc12_40.2 (%HoldsType), %a.param_patt: ) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -814,7 +814,7 @@ fn G() { // CHECK:STDOUT: %.loc24_27.1: init %array_type = converted %.loc24_25.1, %.loc24_25.5 [concrete = constants.%array] // CHECK:STDOUT: %.loc24_27.2: ref %array_type = temporary %.loc24_25.2, %.loc24_27.1 // CHECK:STDOUT: %.loc24_27.3: %array_type = bind_value %.loc24_27.2 -// CHECK:STDOUT: %.loc24_43: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc24_48: %empty_struct_type = struct_literal () // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -828,7 +828,7 @@ fn G() { // CHECK:STDOUT: specific @F(constants.%T) { // CHECK:STDOUT: %T.loc12_6.2 => constants.%T // CHECK:STDOUT: %T.patt.loc12_6.2 => constants.%T -// CHECK:STDOUT: %HoldsType.loc12_35.2 => constants.%HoldsType +// CHECK:STDOUT: %HoldsType.loc12_40.2 => constants.%HoldsType // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @HoldsType(@F.%T.loc12_6.2) {} diff --git a/toolchain/check/testdata/builtins/int/and.carbon b/toolchain/check/testdata/builtins/int/and.carbon index f624ff011d09..cde56b841a99 100644 --- a/toolchain/check/testdata/builtins/int/and.carbon +++ b/toolchain/check/testdata/builtins/int/and.carbon @@ -16,8 +16,8 @@ library "[[@TEST_NAME]]"; fn And(a: i32, b: i32) -> i32 = "int.and"; -var arr: [i32; And(12, 10)]; -let arr_p: [i32; 8]* = &arr; +var arr: array(i32, And(12, 10)); +let arr_p: array(i32, 8)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return And(a, b); diff --git a/toolchain/check/testdata/builtins/int/complement.carbon b/toolchain/check/testdata/builtins/int/complement.carbon index a40d2c6960ba..58165355f02a 100644 --- a/toolchain/check/testdata/builtins/int/complement.carbon +++ b/toolchain/check/testdata/builtins/int/complement.carbon @@ -17,8 +17,8 @@ library "[[@TEST_NAME]]"; fn Complement(a: i32) -> i32 = "int.complement"; fn And(a: i32, b: i32) -> i32 = "int.and"; -var arr: [i32; And(Complement(0x123456), 0xFFFFFF)]; -let arr_p: [i32; 0xEDCBA9]* = &arr; +var arr: array(i32, And(Complement(0x123456), 0xFFFFFF)); +let arr_p: array(i32, 0xEDCBA9)* = &arr; fn RuntimeCallIsValid(a: i32) -> i32 { return Complement(a); diff --git a/toolchain/check/testdata/builtins/int/or.carbon b/toolchain/check/testdata/builtins/int/or.carbon index 9dbd3cca8b7e..001df66e5900 100644 --- a/toolchain/check/testdata/builtins/int/or.carbon +++ b/toolchain/check/testdata/builtins/int/or.carbon @@ -14,8 +14,8 @@ fn Or(a: i32, b: i32) -> i32 = "int.or"; -var arr: [i32; Or(12, 10)]; -let arr_p: [i32; 14]* = &arr; +var arr: array(i32, Or(12, 10)); +let arr_p: array(i32, 14)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Or(a, b); diff --git a/toolchain/check/testdata/builtins/int/sadd.carbon b/toolchain/check/testdata/builtins/int/sadd.carbon index 45aa2db79c66..bfd730eac191 100644 --- a/toolchain/check/testdata/builtins/int/sadd.carbon +++ b/toolchain/check/testdata/builtins/int/sadd.carbon @@ -94,30 +94,30 @@ fn MixedAdd3(a: i32, b: Core.IntLiteral()) -> Core.IntLiteral() = "int.sadd"; // CHECK:STDERR: fn MixedAdd4(a: Core.IntLiteral(), b: i32) -> Core.IntLiteral() = "int.sadd"; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:20: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var too_few: [i32; TooFew(1)]; -// CHECK:STDERR: ^~~~~~~~~ +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:25: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var too_few: array(i32, TooFew(1)); +// CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: -var too_few: [i32; TooFew(1)]; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:21: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var too_many: [i32; TooMany(1, 2, 3)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~ +var too_few: array(i32, TooFew(1)); +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:26: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var too_many: array(i32, TooMany(1, 2, 3)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: -var too_many: [i32; TooMany(1, 2, 3)]; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:28: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var bad_return_type: [i32; BadReturnType(1, 2)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ +var too_many: array(i32, TooMany(1, 2, 3)); +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:33: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var bad_return_type: array(i32, BadReturnType(1, 2)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var bad_return_type: [i32; BadReturnType(1, 2)]; +var bad_return_type: array(i32, BadReturnType(1, 2)); -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:21: error: 3 arguments passed to function expecting 2 arguments [CallArgCountMismatch] -// CHECK:STDERR: var bad_call: [i32; JustRight(1, 2, 3)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:26: error: 3 arguments passed to function expecting 2 arguments [CallArgCountMismatch] +// CHECK:STDERR: var bad_call: array(i32, JustRight(1, 2, 3)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-43]]:1: note: calling function declared here [InCallToEntity] // CHECK:STDERR: fn JustRight(a: i32, b: i32) -> i32 = "int.sadd"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var bad_call: [i32; JustRight(1, 2, 3)]; +var bad_call: array(i32, JustRight(1, 2, 3)); fn RuntimeCallIsValidTooFew(a: i32) -> i32 { return TooFew(a); diff --git a/toolchain/check/testdata/builtins/int/sdiv.carbon b/toolchain/check/testdata/builtins/int/sdiv.carbon index 3de44450bb88..1850ce360d6a 100644 --- a/toolchain/check/testdata/builtins/int/sdiv.carbon +++ b/toolchain/check/testdata/builtins/int/sdiv.carbon @@ -14,8 +14,8 @@ fn Div(a: i32, b: i32) -> i32 = "int.sdiv"; -var arr: [i32; Div(3, 2)]; -let arr_p: [i32; 1]* = &arr; +var arr: array(i32, Div(3, 2)); +let arr_p: array(i32, 1)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Div(a, b); diff --git a/toolchain/check/testdata/builtins/int/smod.carbon b/toolchain/check/testdata/builtins/int/smod.carbon index bd15000b6a26..5e09cb6ab586 100644 --- a/toolchain/check/testdata/builtins/int/smod.carbon +++ b/toolchain/check/testdata/builtins/int/smod.carbon @@ -14,8 +14,8 @@ fn Mod(a: i32, b: i32) -> i32 = "int.smod"; -var arr: [i32; Mod(5, 3)]; -let arr_p: [i32; 2]* = &arr; +var arr: array(i32, Mod(5, 3)); +let arr_p: array(i32, 2)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Mod(a, b); diff --git a/toolchain/check/testdata/builtins/int/snegate.carbon b/toolchain/check/testdata/builtins/int/snegate.carbon index 1c5a448f0263..1e49effea7c7 100644 --- a/toolchain/check/testdata/builtins/int/snegate.carbon +++ b/toolchain/check/testdata/builtins/int/snegate.carbon @@ -14,8 +14,8 @@ fn Negate(a: i32) -> i32 = "int.snegate"; -var arr: [i32; Negate(Negate(123))]; -let arr_p: [i32; 123]* = &arr; +var arr: array(i32, Negate(Negate(123))); +let arr_p: array(i32, 123)* = &arr; let n: i32 = Negate(1); @@ -59,30 +59,30 @@ fn TooMany(a: i32, b: i32) -> i32 = "int.snegate"; fn BadReturnType(a: i32) -> bool = "int.snegate"; fn JustRight(a: i32) -> i32 = "int.snegate"; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:20: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var too_few: [i32; TooFew()]; -// CHECK:STDERR: ^~~~~~~~ +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:25: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var too_few: array(i32, TooFew()); +// CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: -var too_few: [i32; TooFew()]; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:21: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var too_many: [i32; TooMany(1, 2)]; -// CHECK:STDERR: ^~~~~~~~~~~~~ +var too_few: array(i32, TooFew()); +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:26: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var too_many: array(i32, TooMany(1, 2)); +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: -var too_many: [i32; TooMany(1, 2)]; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:28: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var bad_return_type: [i32; BadReturnType(1)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~ +var too_many: array(i32, TooMany(1, 2)); +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:33: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var bad_return_type: array(i32, BadReturnType(1)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: -var bad_return_type: [i32; BadReturnType(1)]; +var bad_return_type: array(i32, BadReturnType(1)); -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:21: error: 2 arguments passed to function expecting 1 argument [CallArgCountMismatch] -// CHECK:STDERR: var bad_call: [i32; JustRight(1, 2)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:26: error: 2 arguments passed to function expecting 1 argument [CallArgCountMismatch] +// CHECK:STDERR: var bad_call: array(i32, JustRight(1, 2)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~ // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-21]]:1: note: calling function declared here [InCallToEntity] // CHECK:STDERR: fn JustRight(a: i32) -> i32 = "int.snegate"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var bad_call: [i32; JustRight(1, 2)]; +var bad_call: array(i32, JustRight(1, 2)); fn RuntimeCallIsValidTooFew(a: i32) -> i32 { // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:10: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch] diff --git a/toolchain/check/testdata/builtins/int/ssub.carbon b/toolchain/check/testdata/builtins/int/ssub.carbon index a52cad1d39f1..c2994dc1a025 100644 --- a/toolchain/check/testdata/builtins/int/ssub.carbon +++ b/toolchain/check/testdata/builtins/int/ssub.carbon @@ -14,8 +14,8 @@ fn Sub(a: i32, b: i32) -> i32 = "int.ssub"; -var arr: [i32; Sub(3, 2)]; -let arr_p: [i32; 1]* = &arr; +var arr: array(i32, Sub(3, 2)); +let arr_p: array(i32, 1)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Sub(a, b); diff --git a/toolchain/check/testdata/builtins/int/uadd.carbon b/toolchain/check/testdata/builtins/int/uadd.carbon index 064caa751627..1954b91e0271 100644 --- a/toolchain/check/testdata/builtins/int/uadd.carbon +++ b/toolchain/check/testdata/builtins/int/uadd.carbon @@ -14,8 +14,8 @@ fn Add(a: i32, b: i32) -> i32 = "int.uadd"; -var arr: [i32; Add(1, 2)]; -let arr_p: [i32; 3]* = &arr; +var arr: array(i32, Add(1, 2)); +let arr_p: array(i32, 3)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Add(a, b); @@ -42,30 +42,30 @@ fn TooMany(a: i32, b: i32, c: i32) -> i32 = "int.uadd"; fn BadReturnType(a: i32, b: i32) -> bool = "int.uadd"; fn JustRight(a: i32, b: i32) -> i32 = "int.uadd"; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:20: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var too_few: [i32; TooFew(1)]; -// CHECK:STDERR: ^~~~~~~~~ +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:25: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var too_few: array(i32, TooFew(1)); +// CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: -var too_few: [i32; TooFew(1)]; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:21: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var too_many: [i32; TooMany(1, 2, 3)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~ +var too_few: array(i32, TooFew(1)); +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:26: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var too_many: array(i32, TooMany(1, 2, 3)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: -var too_many: [i32; TooMany(1, 2, 3)]; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:28: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var bad_return_type: [i32; BadReturnType(1, 2)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ +var too_many: array(i32, TooMany(1, 2, 3)); +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:33: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var bad_return_type: array(i32, BadReturnType(1, 2)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var bad_return_type: [i32; BadReturnType(1, 2)]; +var bad_return_type: array(i32, BadReturnType(1, 2)); -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:21: error: 3 arguments passed to function expecting 2 arguments [CallArgCountMismatch] -// CHECK:STDERR: var bad_call: [i32; JustRight(1, 2, 3)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:26: error: 3 arguments passed to function expecting 2 arguments [CallArgCountMismatch] +// CHECK:STDERR: var bad_call: array(i32, JustRight(1, 2, 3)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-21]]:1: note: calling function declared here [InCallToEntity] // CHECK:STDERR: fn JustRight(a: i32, b: i32) -> i32 = "int.uadd"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var bad_call: [i32; JustRight(1, 2, 3)]; +var bad_call: array(i32, JustRight(1, 2, 3)); fn RuntimeCallIsValidTooFew(a: i32) -> i32 { return TooFew(a); diff --git a/toolchain/check/testdata/builtins/int/udiv.carbon b/toolchain/check/testdata/builtins/int/udiv.carbon index 922034530650..6c6d574fbb40 100644 --- a/toolchain/check/testdata/builtins/int/udiv.carbon +++ b/toolchain/check/testdata/builtins/int/udiv.carbon @@ -14,8 +14,8 @@ fn Div(a: i32, b: i32) -> i32 = "int.udiv"; -var arr: [i32; Div(3, 2)]; -let arr_p: [i32; 1]* = &arr; +var arr: array(i32, Div(3, 2)); +let arr_p: array(i32, 1)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Div(a, b); diff --git a/toolchain/check/testdata/builtins/int/umod.carbon b/toolchain/check/testdata/builtins/int/umod.carbon index 65498af8bea3..471afc30f2ef 100644 --- a/toolchain/check/testdata/builtins/int/umod.carbon +++ b/toolchain/check/testdata/builtins/int/umod.carbon @@ -14,8 +14,8 @@ fn Mod(a: i32, b: i32) -> i32 = "int.umod"; -var arr: [i32; Mod(5, 3)]; -let arr_p: [i32; 2]* = &arr; +var arr: array(i32, Mod(5, 3)); +let arr_p: array(i32, 2)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Mod(a, b); diff --git a/toolchain/check/testdata/builtins/int/umul.carbon b/toolchain/check/testdata/builtins/int/umul.carbon index 40d89a11cd87..f69e85163a22 100644 --- a/toolchain/check/testdata/builtins/int/umul.carbon +++ b/toolchain/check/testdata/builtins/int/umul.carbon @@ -14,8 +14,8 @@ fn Mul(a: i32, b: i32) -> i32 = "int.umul"; -var arr: [i32; Mul(3, 2)]; -let arr_p: [i32; 6]* = &arr; +var arr: array(i32, Mul(3, 2)); +let arr_p: array(i32, 6)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Mul(a, b); diff --git a/toolchain/check/testdata/builtins/int/unegate.carbon b/toolchain/check/testdata/builtins/int/unegate.carbon index 39bdaf6f153c..03160a963e99 100644 --- a/toolchain/check/testdata/builtins/int/unegate.carbon +++ b/toolchain/check/testdata/builtins/int/unegate.carbon @@ -14,8 +14,8 @@ fn Negate(a: u32) -> u32 = "int.unegate"; -var arr: [u32; Negate(Negate(123))]; -let arr_p: [u32; 123]* = &arr; +var arr: array(u32, Negate(Negate(123))); +let arr_p: array(u32, 123)* = &arr; let n: u32 = Negate(1); @@ -44,30 +44,30 @@ fn TooMany(a: u32, b: u32) -> u32 = "int.unegate"; fn BadReturnType(a: u32) -> bool = "int.unegate"; fn JustRight(a: u32) -> u32 = "int.unegate"; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:20: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var too_few: [u32; TooFew()]; -// CHECK:STDERR: ^~~~~~~~ +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:25: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var too_few: array(u32, TooFew()); +// CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: -var too_few: [u32; TooFew()]; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:21: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var too_many: [u32; TooMany(1, 2)]; -// CHECK:STDERR: ^~~~~~~~~~~~~ +var too_few: array(u32, TooFew()); +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:26: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var too_many: array(u32, TooMany(1, 2)); +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: -var too_many: [u32; TooMany(1, 2)]; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:28: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var bad_return_type: [u32; BadReturnType(1)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~ +var too_many: array(u32, TooMany(1, 2)); +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:33: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var bad_return_type: array(u32, BadReturnType(1)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: -var bad_return_type: [u32; BadReturnType(1)]; +var bad_return_type: array(u32, BadReturnType(1)); -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:21: error: 2 arguments passed to function expecting 1 argument [CallArgCountMismatch] -// CHECK:STDERR: var bad_call: [u32; JustRight(1, 2)]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:26: error: 2 arguments passed to function expecting 1 argument [CallArgCountMismatch] +// CHECK:STDERR: var bad_call: array(u32, JustRight(1, 2)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~ // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-21]]:1: note: calling function declared here [InCallToEntity] // CHECK:STDERR: fn JustRight(a: u32) -> u32 = "int.unegate"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var bad_call: [u32; JustRight(1, 2)]; +var bad_call: array(u32, JustRight(1, 2)); fn RuntimeCallIsValidTooFew(a: u32) -> u32 { // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:10: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch] diff --git a/toolchain/check/testdata/builtins/int/usub.carbon b/toolchain/check/testdata/builtins/int/usub.carbon index 662d33f36fba..c4413c9c5014 100644 --- a/toolchain/check/testdata/builtins/int/usub.carbon +++ b/toolchain/check/testdata/builtins/int/usub.carbon @@ -14,8 +14,8 @@ fn Sub(a: i32, b: i32) -> i32 = "int.usub"; -var arr: [i32; Sub(3, 2)]; -let arr_p: [i32; 1]* = &arr; +var arr: array(i32, Sub(3, 2)); +let arr_p: array(i32, 1)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Sub(a, b); diff --git a/toolchain/check/testdata/builtins/int/xor.carbon b/toolchain/check/testdata/builtins/int/xor.carbon index 5471c38e8b83..9a1f2237ea25 100644 --- a/toolchain/check/testdata/builtins/int/xor.carbon +++ b/toolchain/check/testdata/builtins/int/xor.carbon @@ -14,8 +14,8 @@ fn Xor(a: i32, b: i32) -> i32 = "int.xor"; -var arr: [i32; Xor(12, 10)]; -let arr_p: [i32; 6]* = &arr; +var arr: array(i32, Xor(12, 10)); +let arr_p: array(i32, 6)* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Xor(a, b); diff --git a/toolchain/check/testdata/deduce/array.carbon b/toolchain/check/testdata/deduce/array.carbon index f0a3ee5726f1..ac8e2785d638 100644 --- a/toolchain/check/testdata/deduce/array.carbon +++ b/toolchain/check/testdata/deduce/array.carbon @@ -14,10 +14,10 @@ library "[[@TEST_NAME]]"; class C {} -fn F[T:! type](a: [T; 3]) -> T { return a[0]; } +fn F[T:! type](a: array(T, 3)) -> T { return a[0]; } fn G() -> C { - var a: [C; 3] = ({}, {}, {}); + var a: array(C, 3) = ({}, {}, {}); return F(a); } @@ -27,10 +27,10 @@ library "[[@TEST_NAME]]"; class C {} -fn F[N:! Core.IntLiteral()](a: [C; N]) -> i32 { return N; } +fn F[N:! Core.IntLiteral()](a: array(C, N)) -> i32 { return N; } fn G() -> i32 { - var a: [C; 3] = ({}, {}, {}); + var a: array(C, 3) = ({}, {}, {}); return F(a); } @@ -40,10 +40,10 @@ library "[[@TEST_NAME]]"; class C {} -fn F[T:! type, N:! Core.IntLiteral()](a: [T; N]) {} +fn F[T:! type, N:! Core.IntLiteral()](a: array(T, N)) {} fn G() { - var a: [C; 3] = ({}, {}, {}); + var a: array(C, 3) = ({}, {}, {}); F(a); } @@ -53,11 +53,11 @@ library "[[@TEST_NAME]]"; class C {} -fn F[T:! type](a: [T; 2]) -> T { return a[0]; } +fn F[T:! type](a: array(T, 2)) -> T { return a[0]; } fn G() -> C { // TODO: We succeed at deducing T here but fail to convert. Is this the right behavior? - var a: [C; 3] = ({}, {}, {}); + var a: array(C, 3) = ({}, {}, {}); // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+10]]:12: error: cannot implicitly convert from `[C; 3]` to `[C; 2]` [ImplicitAsConversionFailure] // CHECK:STDERR: return F(a); // CHECK:STDERR: ^ @@ -65,8 +65,8 @@ fn G() -> C { // CHECK:STDERR: return F(a); // CHECK:STDERR: ^ // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE-11]]:16: note: initializing function parameter [InCallToFunctionParam] - // CHECK:STDERR: fn F[T:! type](a: [T; 2]) -> T { return a[0]; } - // CHECK:STDERR: ^~~~~~~~~ + // CHECK:STDERR: fn F[T:! type](a: array(T, 2)) -> T { return a[0]; } + // CHECK:STDERR: ^~~~~~~~~~~~~~ // CHECK:STDERR: return F(a); } @@ -78,11 +78,11 @@ library "[[@TEST_NAME]]"; class C {} class D {} -fn F[N:! Core.IntLiteral()](a: [C; N]) -> i32 { return N; } +fn F[N:! Core.IntLiteral()](a: array(C, N)) -> i32 { return N; } fn G() -> i32 { // TODO: We succeed at deducing N here but fail to convert. Is this the right behavior? - var a: [D; 3] = ({}, {}, {}); + var a: array(D, 3) = ({}, {}, {}); // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+10]]:12: error: cannot implicitly convert from `[D; 3]` to `[C; 3]` [ImplicitAsConversionFailure] // CHECK:STDERR: return F(a); // CHECK:STDERR: ^ @@ -90,8 +90,8 @@ fn G() -> i32 { // CHECK:STDERR: return F(a); // CHECK:STDERR: ^ // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE-11]]:29: note: initializing function parameter [InCallToFunctionParam] - // CHECK:STDERR: fn F[N:! Core.IntLiteral()](a: [C; N]) -> i32 { return N; } - // CHECK:STDERR: ^~~~~~~~~ + // CHECK:STDERR: fn F[N:! Core.IntLiteral()](a: array(C, N)) -> i32 { return N; } + // CHECK:STDERR: ^~~~~~~~~~~~~~ // CHECK:STDERR: return F(a); } @@ -102,10 +102,10 @@ library "[[@TEST_NAME]]"; class C {} -fn F[N:! i32](a: [C; N]) -> i32 { return N; } +fn F[N:! i32](a: array(C, N)) -> i32 { return N; } fn G() -> i32 { - var a: [C; 3] = ({}, {}, {}); + var a: array(C, 3) = ({}, {}, {}); // TODO: This fails because the array bound in `F` is effectively // `N.(ImplicitAs(IntLiteral).Convert)()` // which we can't deduce through. We should decide if we want to support @@ -115,8 +115,8 @@ fn G() -> i32 { // CHECK:STDERR: return F(a); // CHECK:STDERR: ^~~~ // CHECK:STDERR: fail_bound_type_mismatch.carbon:[[@LINE-12]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] - // CHECK:STDERR: fn F[N:! i32](a: [C; N]) -> i32 { return N; } - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fn F[N:! i32](a: array(C, N)) -> i32 { return N; } + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: return F(a); } @@ -181,21 +181,21 @@ fn G() -> i32 { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)] // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)] -// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_24.2 (%array_type.743) = binding_pattern a -// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_24.2 (%array_type.743) = value_param_pattern %a.patt, runtime_param0 +// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_29.2 (%array_type.743) = binding_pattern a +// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_29.2 (%array_type.743) = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: %return.patt: @F.%T.loc6_6.2 (%T) = return_slot_pattern // CHECK:STDOUT: %return.param_patt: @F.%T.loc6_6.2 (%T) = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { -// CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc6_35: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %T.param: type = value_param runtime_param // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)] -// CHECK:STDOUT: %a.param: @F.%array_type.loc6_24.2 (%array_type.743) = value_param runtime_param0 -// CHECK:STDOUT: %.loc6_24: type = splice_block %array_type.loc6_24.1 [symbolic = %array_type.loc6_24.2 (constants.%array_type.743)] { -// CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] +// CHECK:STDOUT: %a.param: @F.%array_type.loc6_29.2 (%array_type.743) = value_param runtime_param0 +// CHECK:STDOUT: %.loc6_29: type = splice_block %array_type.loc6_29.1 [symbolic = %array_type.loc6_29.2 (constants.%array_type.743)] { +// CHECK:STDOUT: %T.ref.loc6_25: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] -// CHECK:STDOUT: %array_type.loc6_24.1: type = array_type %int_3, %T [symbolic = %array_type.loc6_24.2 (constants.%array_type.743)] +// CHECK:STDOUT: %array_type.loc6_29.1: type = array_type %int_3, %T [symbolic = %array_type.loc6_29.2 (constants.%array_type.743)] // CHECK:STDOUT: } -// CHECK:STDOUT: %a: @F.%array_type.loc6_24.2 (%array_type.743) = bind_name a, %a.param +// CHECK:STDOUT: %a: @F.%array_type.loc6_29.2 (%array_type.743) = bind_name a, %a.param // CHECK:STDOUT: %return.param: ref @F.%T.loc6_6.2 (%T) = out_param runtime_param1 // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = return_slot %return.param // CHECK:STDOUT: } @@ -220,15 +220,15 @@ fn G() -> i32 { // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) { // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)] -// CHECK:STDOUT: %array_type.loc6_24.2: type = array_type constants.%int_3, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_24.2 (constants.%array_type.743)] +// CHECK:STDOUT: %array_type.loc6_29.2: type = array_type constants.%int_3, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_29.2 (constants.%array_type.743)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete.loc6_27: = require_complete_type @F.%T.loc6_6.2 (%T) [symbolic = %require_complete.loc6_27 (constants.%require_complete.4ae)] -// CHECK:STDOUT: %require_complete.loc6_17: = require_complete_type @F.%array_type.loc6_24.2 (%array_type.743) [symbolic = %require_complete.loc6_17 (constants.%require_complete.06f)] +// CHECK:STDOUT: %require_complete.loc6_32: = require_complete_type @F.%T.loc6_6.2 (%T) [symbolic = %require_complete.loc6_32 (constants.%require_complete.4ae)] +// CHECK:STDOUT: %require_complete.loc6_17: = require_complete_type @F.%array_type.loc6_29.2 (%array_type.743) [symbolic = %require_complete.loc6_17 (constants.%require_complete.06f)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%array_type.loc6_24.2 (%array_type.743)) -> @F.%T.loc6_6.2 (%T) { +// CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%array_type.loc6_29.2 (%array_type.743)) -> @F.%T.loc6_6.2 (%T) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: @F.%array_type.loc6_24.2 (%array_type.743) = name_ref a, %a +// CHECK:STDOUT: %a.ref: @F.%array_type.loc6_29.2 (%array_type.743) = name_ref a, %a // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] @@ -236,12 +236,12 @@ fn G() -> i32 { // CHECK:STDOUT: %bound_method: = bound_method %int_0, %impl.elem0 [concrete = constants.%Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0) [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc6_43.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc6_43.2: %i32 = converted %int_0, %.loc6_43.1 [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc6_44.1: ref @F.%array_type.loc6_24.2 (%array_type.743) = value_as_ref %a.ref -// CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43.2 -// CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2 -// CHECK:STDOUT: return %.loc6_44.3 +// CHECK:STDOUT: %.loc6_48.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc6_48.2: %i32 = converted %int_0, %.loc6_48.1 [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc6_49.1: ref @F.%array_type.loc6_29.2 (%array_type.743) = value_as_ref %a.ref +// CHECK:STDOUT: %.loc6_49.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_49.1, %.loc6_48.2 +// CHECK:STDOUT: %.loc6_49.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_49.2 +// CHECK:STDOUT: return %.loc6_49.3 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -252,26 +252,26 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1) +// CHECK:STDOUT: %.loc9_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_30.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_34.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_35.1: %tuple.type = tuple_literal (%.loc9_26.1, %.loc9_30.1, %.loc9_34.1) // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0 -// CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.2: ref %C = array_index %a.var, %int_0 +// CHECK:STDOUT: %.loc9_26.2: init %C = class_init (), %.loc9_35.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.3: init %C = converted %.loc9_26.1, %.loc9_26.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1 -// CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.4: ref %C = array_index %a.var, %int_1 +// CHECK:STDOUT: %.loc9_30.2: init %C = class_init (), %.loc9_35.4 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.5: init %C = converted %.loc9_30.1, %.loc9_30.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2 -// CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc9_35.6: ref %C = array_index %a.var, %int_2 +// CHECK:STDOUT: %.loc9_34.2: init %C = class_init (), %.loc9_35.6 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.7: init %C = converted %.loc9_34.1, %.loc9_34.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.8: init %array_type.002 = array_init (%.loc9_35.3, %.loc9_35.5, %.loc9_35.7) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_35.1, %.loc9_35.8 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc9_3.2 -// CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [concrete = constants.%array_type.002] { +// CHECK:STDOUT: %.loc9_20: type = splice_block %array_type [concrete = constants.%array_type.002] { // CHECK:STDOUT: %C.ref.loc9: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [concrete = constants.%array_type.002] @@ -289,16 +289,16 @@ fn G() -> i32 { // CHECK:STDOUT: specific @F(constants.%T) { // CHECK:STDOUT: %T.loc6_6.2 => constants.%T // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T -// CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.743 +// CHECK:STDOUT: %array_type.loc6_29.2 => constants.%array_type.743 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%C) { // CHECK:STDOUT: %T.loc6_6.2 => constants.%C // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C -// CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.002 +// CHECK:STDOUT: %array_type.loc6_29.2 => constants.%array_type.002 // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete.loc6_27 => constants.%complete_type.357 +// CHECK:STDOUT: %require_complete.loc6_32 => constants.%complete_type.357 // CHECK:STDOUT: %require_complete.loc6_17 => constants.%complete_type.dd1 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -368,8 +368,8 @@ fn G() -> i32 { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %N.patt.loc6_6.1: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc6_6.2 (constants.%N.patt)] // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc6_6.1, runtime_param [symbolic = %N.patt.loc6_6.2 (constants.%N.patt)] -// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_37.2 (%array_type.6a2) = binding_pattern a -// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_37.2 (%array_type.6a2) = value_param_pattern %a.patt, runtime_param0 +// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_42.2 (%array_type.6a2) = binding_pattern a +// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_42.2 (%array_type.6a2) = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { @@ -384,13 +384,13 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc6_26.3: type = converted %int_literal.make_type, %.loc6_26.2 [concrete = Core.IntLiteral] // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc6_6.1: Core.IntLiteral = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc6_6.2 (constants.%N)] -// CHECK:STDOUT: %a.param: @F.%array_type.loc6_37.2 (%array_type.6a2) = value_param runtime_param0 -// CHECK:STDOUT: %.loc6_37: type = splice_block %array_type.loc6_37.1 [symbolic = %array_type.loc6_37.2 (constants.%array_type.6a2)] { +// CHECK:STDOUT: %a.param: @F.%array_type.loc6_42.2 (%array_type.6a2) = value_param runtime_param0 +// CHECK:STDOUT: %.loc6_42: type = splice_block %array_type.loc6_42.1 [symbolic = %array_type.loc6_42.2 (constants.%array_type.6a2)] { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %N.ref.loc6_36: Core.IntLiteral = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N)] -// CHECK:STDOUT: %array_type.loc6_37.1: type = array_type %N.ref.loc6_36, %C [symbolic = %array_type.loc6_37.2 (constants.%array_type.6a2)] +// CHECK:STDOUT: %N.ref.loc6_41: Core.IntLiteral = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N)] +// CHECK:STDOUT: %array_type.loc6_42.1: type = array_type %N.ref.loc6_41, %C [symbolic = %array_type.loc6_42.2 (constants.%array_type.6a2)] // CHECK:STDOUT: } -// CHECK:STDOUT: %a: @F.%array_type.loc6_37.2 (%array_type.6a2) = bind_name a, %a.param +// CHECK:STDOUT: %a: @F.%array_type.loc6_42.2 (%array_type.6a2) = bind_name a, %a.param // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -416,24 +416,24 @@ fn G() -> i32 { // CHECK:STDOUT: generic fn @F(%N.loc6_6.1: Core.IntLiteral) { // CHECK:STDOUT: %N.loc6_6.2: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N.loc6_6.2 (constants.%N)] // CHECK:STDOUT: %N.patt.loc6_6.2: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc6_6.2 (constants.%N.patt)] -// CHECK:STDOUT: %array_type.loc6_37.2: type = array_type %N.loc6_6.2, %C [symbolic = %array_type.loc6_37.2 (constants.%array_type.6a2)] +// CHECK:STDOUT: %array_type.loc6_42.2: type = array_type %N.loc6_6.2, %C [symbolic = %array_type.loc6_42.2 (constants.%array_type.6a2)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc6_37.2 (%array_type.6a2) [symbolic = %require_complete (constants.%require_complete.d82)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc6_42.2 (%array_type.6a2) [symbolic = %require_complete (constants.%require_complete.d82)] // CHECK:STDOUT: %Convert.bound: = bound_method %N.loc6_6.2, constants.%Convert.956 [symbolic = %Convert.bound (constants.%Convert.bound.41f)] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn.122)] -// CHECK:STDOUT: %int.convert_checked.loc6_57.2: init %i32 = call %Convert.specific_fn(%N.loc6_6.2) [symbolic = %int.convert_checked.loc6_57.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %int.convert_checked.loc6_62.2: init %i32 = call %Convert.specific_fn(%N.loc6_6.2) [symbolic = %int.convert_checked.loc6_62.2 (constants.%int.convert_checked)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc6_37.2 (%array_type.6a2)) -> %i32 { +// CHECK:STDOUT: fn[%N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc6_42.2 (%array_type.6a2)) -> %i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %N.ref.loc6_56: Core.IntLiteral = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N)] +// CHECK:STDOUT: %N.ref.loc6_61: Core.IntLiteral = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N)] // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method: = bound_method %N.ref.loc6_56, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound.41f)] +// CHECK:STDOUT: %bound_method: = bound_method %N.ref.loc6_61, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound.41f)] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn.122)] -// CHECK:STDOUT: %int.convert_checked.loc6_57.1: init %i32 = call %specific_fn(%N.ref.loc6_56) [symbolic = %int.convert_checked.loc6_57.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc6_57.1: %i32 = value_of_initializer %int.convert_checked.loc6_57.1 [symbolic = %int.convert_checked.loc6_57.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc6_57.2: %i32 = converted %N.ref.loc6_56, %.loc6_57.1 [symbolic = %int.convert_checked.loc6_57.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: return %.loc6_57.2 +// CHECK:STDOUT: %int.convert_checked.loc6_62.1: init %i32 = call %specific_fn(%N.ref.loc6_61) [symbolic = %int.convert_checked.loc6_62.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc6_62.1: %i32 = value_of_initializer %int.convert_checked.loc6_62.1 [symbolic = %int.convert_checked.loc6_62.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc6_62.2: %i32 = converted %N.ref.loc6_61, %.loc6_62.1 [symbolic = %int.convert_checked.loc6_62.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: return %.loc6_62.2 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -444,26 +444,26 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1) +// CHECK:STDOUT: %.loc9_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_30.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_34.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_35.1: %tuple.type = tuple_literal (%.loc9_26.1, %.loc9_30.1, %.loc9_34.1) // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0 -// CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.2: ref %C = array_index %a.var, %int_0 +// CHECK:STDOUT: %.loc9_26.2: init %C = class_init (), %.loc9_35.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.3: init %C = converted %.loc9_26.1, %.loc9_26.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1 -// CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.4: ref %C = array_index %a.var, %int_1 +// CHECK:STDOUT: %.loc9_30.2: init %C = class_init (), %.loc9_35.4 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.5: init %C = converted %.loc9_30.1, %.loc9_30.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2 -// CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc9_35.6: ref %C = array_index %a.var, %int_2 +// CHECK:STDOUT: %.loc9_34.2: init %C = class_init (), %.loc9_35.6 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.7: init %C = converted %.loc9_34.1, %.loc9_34.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.8: init %array_type.002 = array_init (%.loc9_35.3, %.loc9_35.5, %.loc9_35.7) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_35.1, %.loc9_35.8 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc9_3.2 -// CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [concrete = constants.%array_type.002] { +// CHECK:STDOUT: %.loc9_20: type = splice_block %array_type [concrete = constants.%array_type.002] { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [concrete = constants.%array_type.002] @@ -482,19 +482,19 @@ fn G() -> i32 { // CHECK:STDOUT: specific @F(constants.%N) { // CHECK:STDOUT: %N.loc6_6.2 => constants.%N // CHECK:STDOUT: %N.patt.loc6_6.2 => constants.%N -// CHECK:STDOUT: %array_type.loc6_37.2 => constants.%array_type.6a2 +// CHECK:STDOUT: %array_type.loc6_42.2 => constants.%array_type.6a2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%int_3.1ba) { // CHECK:STDOUT: %N.loc6_6.2 => constants.%int_3.1ba // CHECK:STDOUT: %N.patt.loc6_6.2 => constants.%int_3.1ba -// CHECK:STDOUT: %array_type.loc6_37.2 => constants.%array_type.002 +// CHECK:STDOUT: %array_type.loc6_42.2 => constants.%array_type.002 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete => constants.%complete_type.dd1 // CHECK:STDOUT: %Convert.bound => constants.%Convert.bound.b30 // CHECK:STDOUT: %Convert.specific_fn => constants.%Convert.specific_fn.b42 -// CHECK:STDOUT: %int.convert_checked.loc6_57.2 => constants.%int_3.822 +// CHECK:STDOUT: %int.convert_checked.loc6_62.2 => constants.%int_3.822 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- type_and_bound.carbon @@ -551,8 +551,8 @@ fn G() -> i32 { // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)] // CHECK:STDOUT: %N.patt.loc6_16.1: Core.IntLiteral = symbolic_binding_pattern N, 1 [symbolic = %N.patt.loc6_16.2 (constants.%N.patt)] // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc6_16.1, runtime_param [symbolic = %N.patt.loc6_16.2 (constants.%N.patt)] -// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_47.2 (%array_type.bb5) = binding_pattern a -// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_47.2 (%array_type.bb5) = value_param_pattern %a.patt, runtime_param0 +// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_52.2 (%array_type.bb5) = binding_pattern a +// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_52.2 (%array_type.bb5) = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %T.param: type = value_param runtime_param // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)] @@ -565,13 +565,13 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc6_36.3: type = converted %int_literal.make_type, %.loc6_36.2 [concrete = Core.IntLiteral] // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc6_16.1: Core.IntLiteral = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc6_16.2 (constants.%N)] -// CHECK:STDOUT: %a.param: @F.%array_type.loc6_47.2 (%array_type.bb5) = value_param runtime_param0 -// CHECK:STDOUT: %.loc6_47: type = splice_block %array_type.loc6_47.1 [symbolic = %array_type.loc6_47.2 (constants.%array_type.bb5)] { +// CHECK:STDOUT: %a.param: @F.%array_type.loc6_52.2 (%array_type.bb5) = value_param runtime_param0 +// CHECK:STDOUT: %.loc6_52: type = splice_block %array_type.loc6_52.1 [symbolic = %array_type.loc6_52.2 (constants.%array_type.bb5)] { // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %N.ref: Core.IntLiteral = name_ref N, %N.loc6_16.1 [symbolic = %N.loc6_16.2 (constants.%N)] -// CHECK:STDOUT: %array_type.loc6_47.1: type = array_type %N.ref, %T [symbolic = %array_type.loc6_47.2 (constants.%array_type.bb5)] +// CHECK:STDOUT: %array_type.loc6_52.1: type = array_type %N.ref, %T [symbolic = %array_type.loc6_52.2 (constants.%array_type.bb5)] // CHECK:STDOUT: } -// CHECK:STDOUT: %a: @F.%array_type.loc6_47.2 (%array_type.bb5) = bind_name a, %a.param +// CHECK:STDOUT: %a: @F.%array_type.loc6_52.2 (%array_type.bb5) = bind_name a, %a.param // CHECK:STDOUT: } // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {} // CHECK:STDOUT: } @@ -589,12 +589,12 @@ fn G() -> i32 { // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)] // CHECK:STDOUT: %N.loc6_16.2: Core.IntLiteral = bind_symbolic_name N, 1 [symbolic = %N.loc6_16.2 (constants.%N)] // CHECK:STDOUT: %N.patt.loc6_16.2: Core.IntLiteral = symbolic_binding_pattern N, 1 [symbolic = %N.patt.loc6_16.2 (constants.%N.patt)] -// CHECK:STDOUT: %array_type.loc6_47.2: type = array_type %N.loc6_16.2, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_47.2 (constants.%array_type.bb5)] +// CHECK:STDOUT: %array_type.loc6_52.2: type = array_type %N.loc6_16.2, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_52.2 (constants.%array_type.bb5)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc6_47.2 (%array_type.bb5) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc6_52.2 (%array_type.bb5) [symbolic = %require_complete (constants.%require_complete)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%T.param_patt: type, %N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc6_47.2 (%array_type.bb5)) { +// CHECK:STDOUT: fn[%T.param_patt: type, %N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc6_52.2 (%array_type.bb5)) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -607,26 +607,26 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1) +// CHECK:STDOUT: %.loc9_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_30.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_34.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_35.1: %tuple.type = tuple_literal (%.loc9_26.1, %.loc9_30.1, %.loc9_34.1) // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0 -// CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.2: ref %C = array_index %a.var, %int_0 +// CHECK:STDOUT: %.loc9_26.2: init %C = class_init (), %.loc9_35.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.3: init %C = converted %.loc9_26.1, %.loc9_26.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1 -// CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.4: ref %C = array_index %a.var, %int_1 +// CHECK:STDOUT: %.loc9_30.2: init %C = class_init (), %.loc9_35.4 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.5: init %C = converted %.loc9_30.1, %.loc9_30.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2 -// CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc9_35.6: ref %C = array_index %a.var, %int_2 +// CHECK:STDOUT: %.loc9_34.2: init %C = class_init (), %.loc9_35.6 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.7: init %C = converted %.loc9_34.1, %.loc9_34.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.8: init %array_type.002 = array_init (%.loc9_35.3, %.loc9_35.5, %.loc9_35.7) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_35.1, %.loc9_35.8 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc9_3.2 -// CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [concrete = constants.%array_type.002] { +// CHECK:STDOUT: %.loc9_20: type = splice_block %array_type [concrete = constants.%array_type.002] { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [concrete = constants.%array_type.002] @@ -645,7 +645,7 @@ fn G() -> i32 { // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T // CHECK:STDOUT: %N.loc6_16.2 => constants.%N // CHECK:STDOUT: %N.patt.loc6_16.2 => constants.%N -// CHECK:STDOUT: %array_type.loc6_47.2 => constants.%array_type.bb5 +// CHECK:STDOUT: %array_type.loc6_52.2 => constants.%array_type.bb5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%C, constants.%int_3) { @@ -653,7 +653,7 @@ fn G() -> i32 { // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C // CHECK:STDOUT: %N.loc6_16.2 => constants.%int_3 // CHECK:STDOUT: %N.patt.loc6_16.2 => constants.%int_3 -// CHECK:STDOUT: %array_type.loc6_47.2 => constants.%array_type.002 +// CHECK:STDOUT: %array_type.loc6_52.2 => constants.%array_type.002 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete => constants.%complete_type.dd1 @@ -720,21 +720,21 @@ fn G() -> i32 { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)] // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)] -// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_24.2 (%array_type.9d4) = binding_pattern a -// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_24.2 (%array_type.9d4) = value_param_pattern %a.patt, runtime_param0 +// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_29.2 (%array_type.9d4) = binding_pattern a +// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_29.2 (%array_type.9d4) = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: %return.patt: @F.%T.loc6_6.2 (%T) = return_slot_pattern // CHECK:STDOUT: %return.param_patt: @F.%T.loc6_6.2 (%T) = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { -// CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc6_35: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %T.param: type = value_param runtime_param // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)] -// CHECK:STDOUT: %a.param: @F.%array_type.loc6_24.2 (%array_type.9d4) = value_param runtime_param0 -// CHECK:STDOUT: %.loc6_24: type = splice_block %array_type.loc6_24.1 [symbolic = %array_type.loc6_24.2 (constants.%array_type.9d4)] { -// CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] +// CHECK:STDOUT: %a.param: @F.%array_type.loc6_29.2 (%array_type.9d4) = value_param runtime_param0 +// CHECK:STDOUT: %.loc6_29: type = splice_block %array_type.loc6_29.1 [symbolic = %array_type.loc6_29.2 (constants.%array_type.9d4)] { +// CHECK:STDOUT: %T.ref.loc6_25: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %array_type.loc6_24.1: type = array_type %int_2, %T [symbolic = %array_type.loc6_24.2 (constants.%array_type.9d4)] +// CHECK:STDOUT: %array_type.loc6_29.1: type = array_type %int_2, %T [symbolic = %array_type.loc6_29.2 (constants.%array_type.9d4)] // CHECK:STDOUT: } -// CHECK:STDOUT: %a: @F.%array_type.loc6_24.2 (%array_type.9d4) = bind_name a, %a.param +// CHECK:STDOUT: %a: @F.%array_type.loc6_29.2 (%array_type.9d4) = bind_name a, %a.param // CHECK:STDOUT: %return.param: ref @F.%T.loc6_6.2 (%T) = out_param runtime_param1 // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = return_slot %return.param // CHECK:STDOUT: } @@ -759,15 +759,15 @@ fn G() -> i32 { // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) { // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)] -// CHECK:STDOUT: %array_type.loc6_24.2: type = array_type constants.%int_2, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_24.2 (constants.%array_type.9d4)] +// CHECK:STDOUT: %array_type.loc6_29.2: type = array_type constants.%int_2, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_29.2 (constants.%array_type.9d4)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete.loc6_27: = require_complete_type @F.%T.loc6_6.2 (%T) [symbolic = %require_complete.loc6_27 (constants.%require_complete.4ae)] -// CHECK:STDOUT: %require_complete.loc6_17: = require_complete_type @F.%array_type.loc6_24.2 (%array_type.9d4) [symbolic = %require_complete.loc6_17 (constants.%require_complete.d11)] +// CHECK:STDOUT: %require_complete.loc6_32: = require_complete_type @F.%T.loc6_6.2 (%T) [symbolic = %require_complete.loc6_32 (constants.%require_complete.4ae)] +// CHECK:STDOUT: %require_complete.loc6_17: = require_complete_type @F.%array_type.loc6_29.2 (%array_type.9d4) [symbolic = %require_complete.loc6_17 (constants.%require_complete.d11)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%array_type.loc6_24.2 (%array_type.9d4)) -> @F.%T.loc6_6.2 (%T) { +// CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%array_type.loc6_29.2 (%array_type.9d4)) -> @F.%T.loc6_6.2 (%T) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: @F.%array_type.loc6_24.2 (%array_type.9d4) = name_ref a, %a +// CHECK:STDOUT: %a.ref: @F.%array_type.loc6_29.2 (%array_type.9d4) = name_ref a, %a // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] @@ -775,12 +775,12 @@ fn G() -> i32 { // CHECK:STDOUT: %bound_method: = bound_method %int_0, %impl.elem0 [concrete = constants.%Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0) [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc6_43.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc6_43.2: %i32 = converted %int_0, %.loc6_43.1 [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc6_44.1: ref @F.%array_type.loc6_24.2 (%array_type.9d4) = value_as_ref %a.ref -// CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43.2 -// CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2 -// CHECK:STDOUT: return %.loc6_44.3 +// CHECK:STDOUT: %.loc6_48.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc6_48.2: %i32 = converted %int_0, %.loc6_48.1 [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc6_49.1: ref @F.%array_type.loc6_29.2 (%array_type.9d4) = value_as_ref %a.ref +// CHECK:STDOUT: %.loc6_49.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_49.1, %.loc6_48.2 +// CHECK:STDOUT: %.loc6_49.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_49.2 +// CHECK:STDOUT: return %.loc6_49.3 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -791,26 +791,26 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc10_3.1: %array_type.002 = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %.loc10_21.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc10_25.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc10_29.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc10_30.1: %tuple.type = tuple_literal (%.loc10_21.1, %.loc10_25.1, %.loc10_29.1) +// CHECK:STDOUT: %.loc10_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc10_30.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc10_34.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc10_35.1: %tuple.type = tuple_literal (%.loc10_26.1, %.loc10_30.1, %.loc10_34.1) // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc10_30.2: ref %C = array_index %a.var, %int_0 -// CHECK:STDOUT: %.loc10_21.2: init %C = class_init (), %.loc10_30.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc10_30.3: init %C = converted %.loc10_21.1, %.loc10_21.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc10_35.2: ref %C = array_index %a.var, %int_0 +// CHECK:STDOUT: %.loc10_26.2: init %C = class_init (), %.loc10_35.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc10_35.3: init %C = converted %.loc10_26.1, %.loc10_26.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc10_30.4: ref %C = array_index %a.var, %int_1 -// CHECK:STDOUT: %.loc10_25.2: init %C = class_init (), %.loc10_30.4 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc10_30.5: init %C = converted %.loc10_25.1, %.loc10_25.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc10_35.4: ref %C = array_index %a.var, %int_1 +// CHECK:STDOUT: %.loc10_30.2: init %C = class_init (), %.loc10_35.4 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc10_35.5: init %C = converted %.loc10_30.1, %.loc10_30.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc10_30.6: ref %C = array_index %a.var, %int_2 -// CHECK:STDOUT: %.loc10_29.2: init %C = class_init (), %.loc10_30.6 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc10_30.7: init %C = converted %.loc10_29.1, %.loc10_29.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc10_30.8: init %array_type.002 = array_init (%.loc10_30.3, %.loc10_30.5, %.loc10_30.7) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc10_3.2: init %array_type.002 = converted %.loc10_30.1, %.loc10_30.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc10_35.6: ref %C = array_index %a.var, %int_2 +// CHECK:STDOUT: %.loc10_34.2: init %C = class_init (), %.loc10_35.6 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc10_35.7: init %C = converted %.loc10_34.1, %.loc10_34.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc10_35.8: init %array_type.002 = array_init (%.loc10_35.3, %.loc10_35.5, %.loc10_35.7) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc10_3.2: init %array_type.002 = converted %.loc10_35.1, %.loc10_35.8 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc10_3.2 -// CHECK:STDOUT: %.loc10_15: type = splice_block %array_type [concrete = constants.%array_type.002] { +// CHECK:STDOUT: %.loc10_20: type = splice_block %array_type [concrete = constants.%array_type.002] { // CHECK:STDOUT: %C.ref.loc10: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [concrete = constants.%array_type.002] @@ -828,16 +828,16 @@ fn G() -> i32 { // CHECK:STDOUT: specific @F(constants.%T) { // CHECK:STDOUT: %T.loc6_6.2 => constants.%T // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T -// CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.9d4 +// CHECK:STDOUT: %array_type.loc6_29.2 => constants.%array_type.9d4 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%C) { // CHECK:STDOUT: %T.loc6_6.2 => constants.%C // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C -// CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.15a +// CHECK:STDOUT: %array_type.loc6_29.2 => constants.%array_type.15a // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete.loc6_27 => constants.%complete_type.357 +// CHECK:STDOUT: %require_complete.loc6_32 => constants.%complete_type.357 // CHECK:STDOUT: %require_complete.loc6_17 => constants.%complete_type.8eb // CHECK:STDOUT: } // CHECK:STDOUT: @@ -911,8 +911,8 @@ fn G() -> i32 { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %N.patt.loc7_6.1: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc7_6.2 (constants.%N.patt)] // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc7_6.1, runtime_param [symbolic = %N.patt.loc7_6.2 (constants.%N.patt)] -// CHECK:STDOUT: %a.patt: @F.%array_type.loc7_37.2 (%array_type.6a2) = binding_pattern a -// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc7_37.2 (%array_type.6a2) = value_param_pattern %a.patt, runtime_param0 +// CHECK:STDOUT: %a.patt: @F.%array_type.loc7_42.2 (%array_type.6a2) = binding_pattern a +// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc7_42.2 (%array_type.6a2) = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { @@ -927,13 +927,13 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc7_26.3: type = converted %int_literal.make_type, %.loc7_26.2 [concrete = Core.IntLiteral] // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc7_6.1: Core.IntLiteral = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc7_6.2 (constants.%N)] -// CHECK:STDOUT: %a.param: @F.%array_type.loc7_37.2 (%array_type.6a2) = value_param runtime_param0 -// CHECK:STDOUT: %.loc7_37: type = splice_block %array_type.loc7_37.1 [symbolic = %array_type.loc7_37.2 (constants.%array_type.6a2)] { +// CHECK:STDOUT: %a.param: @F.%array_type.loc7_42.2 (%array_type.6a2) = value_param runtime_param0 +// CHECK:STDOUT: %.loc7_42: type = splice_block %array_type.loc7_42.1 [symbolic = %array_type.loc7_42.2 (constants.%array_type.6a2)] { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %N.ref.loc7_36: Core.IntLiteral = name_ref N, %N.loc7_6.1 [symbolic = %N.loc7_6.2 (constants.%N)] -// CHECK:STDOUT: %array_type.loc7_37.1: type = array_type %N.ref.loc7_36, %C [symbolic = %array_type.loc7_37.2 (constants.%array_type.6a2)] +// CHECK:STDOUT: %N.ref.loc7_41: Core.IntLiteral = name_ref N, %N.loc7_6.1 [symbolic = %N.loc7_6.2 (constants.%N)] +// CHECK:STDOUT: %array_type.loc7_42.1: type = array_type %N.ref.loc7_41, %C [symbolic = %array_type.loc7_42.2 (constants.%array_type.6a2)] // CHECK:STDOUT: } -// CHECK:STDOUT: %a: @F.%array_type.loc7_37.2 (%array_type.6a2) = bind_name a, %a.param +// CHECK:STDOUT: %a: @F.%array_type.loc7_42.2 (%array_type.6a2) = bind_name a, %a.param // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -967,24 +967,24 @@ fn G() -> i32 { // CHECK:STDOUT: generic fn @F(%N.loc7_6.1: Core.IntLiteral) { // CHECK:STDOUT: %N.loc7_6.2: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N.loc7_6.2 (constants.%N)] // CHECK:STDOUT: %N.patt.loc7_6.2: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc7_6.2 (constants.%N.patt)] -// CHECK:STDOUT: %array_type.loc7_37.2: type = array_type %N.loc7_6.2, %C [symbolic = %array_type.loc7_37.2 (constants.%array_type.6a2)] +// CHECK:STDOUT: %array_type.loc7_42.2: type = array_type %N.loc7_6.2, %C [symbolic = %array_type.loc7_42.2 (constants.%array_type.6a2)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc7_37.2 (%array_type.6a2) [symbolic = %require_complete (constants.%require_complete.d82)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc7_42.2 (%array_type.6a2) [symbolic = %require_complete (constants.%require_complete.d82)] // CHECK:STDOUT: %Convert.bound: = bound_method %N.loc7_6.2, constants.%Convert.956 [symbolic = %Convert.bound (constants.%Convert.bound.41f)] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn.122)] -// CHECK:STDOUT: %int.convert_checked.loc7_57.2: init %i32 = call %Convert.specific_fn(%N.loc7_6.2) [symbolic = %int.convert_checked.loc7_57.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %int.convert_checked.loc7_62.2: init %i32 = call %Convert.specific_fn(%N.loc7_6.2) [symbolic = %int.convert_checked.loc7_62.2 (constants.%int.convert_checked)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc7_37.2 (%array_type.6a2)) -> %i32 { +// CHECK:STDOUT: fn[%N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc7_42.2 (%array_type.6a2)) -> %i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %N.ref.loc7_56: Core.IntLiteral = name_ref N, %N.loc7_6.1 [symbolic = %N.loc7_6.2 (constants.%N)] +// CHECK:STDOUT: %N.ref.loc7_61: Core.IntLiteral = name_ref N, %N.loc7_6.1 [symbolic = %N.loc7_6.2 (constants.%N)] // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method: = bound_method %N.ref.loc7_56, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound.41f)] +// CHECK:STDOUT: %bound_method: = bound_method %N.ref.loc7_61, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound.41f)] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn.122)] -// CHECK:STDOUT: %int.convert_checked.loc7_57.1: init %i32 = call %specific_fn(%N.ref.loc7_56) [symbolic = %int.convert_checked.loc7_57.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc7_57.1: %i32 = value_of_initializer %int.convert_checked.loc7_57.1 [symbolic = %int.convert_checked.loc7_57.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc7_57.2: %i32 = converted %N.ref.loc7_56, %.loc7_57.1 [symbolic = %int.convert_checked.loc7_57.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: return %.loc7_57.2 +// CHECK:STDOUT: %int.convert_checked.loc7_62.1: init %i32 = call %specific_fn(%N.ref.loc7_61) [symbolic = %int.convert_checked.loc7_62.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc7_62.1: %i32 = value_of_initializer %int.convert_checked.loc7_62.1 [symbolic = %int.convert_checked.loc7_62.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc7_62.2: %i32 = converted %N.ref.loc7_61, %.loc7_62.1 [symbolic = %int.convert_checked.loc7_62.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: return %.loc7_62.2 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -995,26 +995,26 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc11_3.1: %array_type.fe4 = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.fe4 = var a -// CHECK:STDOUT: %.loc11_21.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc11_25.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc11_29.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc11_30.1: %tuple.type = tuple_literal (%.loc11_21.1, %.loc11_25.1, %.loc11_29.1) +// CHECK:STDOUT: %.loc11_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc11_30.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc11_34.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc11_35.1: %tuple.type = tuple_literal (%.loc11_26.1, %.loc11_30.1, %.loc11_34.1) // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_30.2: ref %D = array_index %a.var, %int_0 -// CHECK:STDOUT: %.loc11_21.2: init %D = class_init (), %.loc11_30.2 [concrete = constants.%D.val] -// CHECK:STDOUT: %.loc11_30.3: init %D = converted %.loc11_21.1, %.loc11_21.2 [concrete = constants.%D.val] +// CHECK:STDOUT: %.loc11_35.2: ref %D = array_index %a.var, %int_0 +// CHECK:STDOUT: %.loc11_26.2: init %D = class_init (), %.loc11_35.2 [concrete = constants.%D.val] +// CHECK:STDOUT: %.loc11_35.3: init %D = converted %.loc11_26.1, %.loc11_26.2 [concrete = constants.%D.val] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc11_30.4: ref %D = array_index %a.var, %int_1 -// CHECK:STDOUT: %.loc11_25.2: init %D = class_init (), %.loc11_30.4 [concrete = constants.%D.val] -// CHECK:STDOUT: %.loc11_30.5: init %D = converted %.loc11_25.1, %.loc11_25.2 [concrete = constants.%D.val] +// CHECK:STDOUT: %.loc11_35.4: ref %D = array_index %a.var, %int_1 +// CHECK:STDOUT: %.loc11_30.2: init %D = class_init (), %.loc11_35.4 [concrete = constants.%D.val] +// CHECK:STDOUT: %.loc11_35.5: init %D = converted %.loc11_30.1, %.loc11_30.2 [concrete = constants.%D.val] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc11_30.6: ref %D = array_index %a.var, %int_2 -// CHECK:STDOUT: %.loc11_29.2: init %D = class_init (), %.loc11_30.6 [concrete = constants.%D.val] -// CHECK:STDOUT: %.loc11_30.7: init %D = converted %.loc11_29.1, %.loc11_29.2 [concrete = constants.%D.val] -// CHECK:STDOUT: %.loc11_30.8: init %array_type.fe4 = array_init (%.loc11_30.3, %.loc11_30.5, %.loc11_30.7) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_3.2: init %array_type.fe4 = converted %.loc11_30.1, %.loc11_30.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_35.6: ref %D = array_index %a.var, %int_2 +// CHECK:STDOUT: %.loc11_34.2: init %D = class_init (), %.loc11_35.6 [concrete = constants.%D.val] +// CHECK:STDOUT: %.loc11_35.7: init %D = converted %.loc11_34.1, %.loc11_34.2 [concrete = constants.%D.val] +// CHECK:STDOUT: %.loc11_35.8: init %array_type.fe4 = array_init (%.loc11_35.3, %.loc11_35.5, %.loc11_35.7) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_3.2: init %array_type.fe4 = converted %.loc11_35.1, %.loc11_35.8 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc11_3.2 -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type.fe4] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type.fe4] { // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] // CHECK:STDOUT: %array_type: type = array_type %int_3, %D [concrete = constants.%array_type.fe4] @@ -1033,19 +1033,19 @@ fn G() -> i32 { // CHECK:STDOUT: specific @F(constants.%N) { // CHECK:STDOUT: %N.loc7_6.2 => constants.%N // CHECK:STDOUT: %N.patt.loc7_6.2 => constants.%N -// CHECK:STDOUT: %array_type.loc7_37.2 => constants.%array_type.6a2 +// CHECK:STDOUT: %array_type.loc7_42.2 => constants.%array_type.6a2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%int_3.1ba) { // CHECK:STDOUT: %N.loc7_6.2 => constants.%int_3.1ba // CHECK:STDOUT: %N.patt.loc7_6.2 => constants.%int_3.1ba -// CHECK:STDOUT: %array_type.loc7_37.2 => constants.%array_type.002 +// CHECK:STDOUT: %array_type.loc7_42.2 => constants.%array_type.002 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete => constants.%complete_type.dd1 // CHECK:STDOUT: %Convert.bound => constants.%Convert.bound.b30 // CHECK:STDOUT: %Convert.specific_fn => constants.%Convert.specific_fn.b42 -// CHECK:STDOUT: %int.convert_checked.loc7_57.2 => constants.%int_3.822 +// CHECK:STDOUT: %int.convert_checked.loc7_62.2 => constants.%int_3.822 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_bound_type_mismatch.carbon @@ -1105,32 +1105,32 @@ fn G() -> i32 { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %N.patt.loc6_6.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc6_6.2 (constants.%N.patt.8e2)] // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc6_6.1, runtime_param [symbolic = %N.patt.loc6_6.2 (constants.%N.patt.8e2)] -// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_23.2 (%array_type.c13) = binding_pattern a -// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_23.2 (%array_type.c13) = value_param_pattern %a.patt, runtime_param0 +// CHECK:STDOUT: %a.patt: @F.%array_type.loc6_28.2 (%array_type.c13) = binding_pattern a +// CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_28.2 (%array_type.c13) = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32.loc6_29: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc6_29: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %int_32.loc6_34: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc6_34: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param // CHECK:STDOUT: %.loc6_10: type = splice_block %i32.loc6_10 [concrete = constants.%i32] { // CHECK:STDOUT: %int_32.loc6_10: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc6_10: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc6_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc6_6.2 (constants.%N.51e)] -// CHECK:STDOUT: %a.param: @F.%array_type.loc6_23.2 (%array_type.c13) = value_param runtime_param0 -// CHECK:STDOUT: %.loc6_23: type = splice_block %array_type.loc6_23.1 [symbolic = %array_type.loc6_23.2 (constants.%array_type.c13)] { +// CHECK:STDOUT: %a.param: @F.%array_type.loc6_28.2 (%array_type.c13) = value_param runtime_param0 +// CHECK:STDOUT: %.loc6_28: type = splice_block %array_type.loc6_28.1 [symbolic = %array_type.loc6_28.2 (constants.%array_type.c13)] { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %N.ref.loc6_22: %i32 = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N.51e)] +// CHECK:STDOUT: %N.ref.loc6_27: %i32 = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N.51e)] // CHECK:STDOUT: %impl.elem0: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] -// CHECK:STDOUT: %bound_method: = bound_method %N.ref.loc6_22, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound)] +// CHECK:STDOUT: %bound_method: = bound_method %N.ref.loc6_27, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound)] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked.loc6_22.1: init Core.IntLiteral = call %specific_fn(%N.ref.loc6_22) [symbolic = %int.convert_checked.loc6_22.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc6_22.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc6_22.1 [symbolic = %int.convert_checked.loc6_22.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc6_22.2: Core.IntLiteral = converted %N.ref.loc6_22, %.loc6_22.1 [symbolic = %int.convert_checked.loc6_22.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc6_23.1: type = array_type %.loc6_22.2, %C [symbolic = %array_type.loc6_23.2 (constants.%array_type.c13)] +// CHECK:STDOUT: %int.convert_checked.loc6_27.1: init Core.IntLiteral = call %specific_fn(%N.ref.loc6_27) [symbolic = %int.convert_checked.loc6_27.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc6_27.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc6_27.1 [symbolic = %int.convert_checked.loc6_27.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc6_27.2: Core.IntLiteral = converted %N.ref.loc6_27, %.loc6_27.1 [symbolic = %int.convert_checked.loc6_27.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc6_28.1: type = array_type %.loc6_27.2, %C [symbolic = %array_type.loc6_28.2 (constants.%array_type.c13)] // CHECK:STDOUT: } -// CHECK:STDOUT: %a: @F.%array_type.loc6_23.2 (%array_type.c13) = bind_name a, %a.param +// CHECK:STDOUT: %a: @F.%array_type.loc6_28.2 (%array_type.c13) = bind_name a, %a.param // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -1158,16 +1158,16 @@ fn G() -> i32 { // CHECK:STDOUT: %N.patt.loc6_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc6_6.2 (constants.%N.patt.8e2)] // CHECK:STDOUT: %Convert.bound: = bound_method %N.loc6_6.2, constants.%Convert.960 [symbolic = %Convert.bound (constants.%Convert.bound)] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked.loc6_22.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc6_6.2) [symbolic = %int.convert_checked.loc6_22.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc6_23.2: type = array_type %int.convert_checked.loc6_22.2, %C [symbolic = %array_type.loc6_23.2 (constants.%array_type.c13)] +// CHECK:STDOUT: %int.convert_checked.loc6_27.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc6_6.2) [symbolic = %int.convert_checked.loc6_27.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc6_28.2: type = array_type %int.convert_checked.loc6_27.2, %C [symbolic = %array_type.loc6_28.2 (constants.%array_type.c13)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc6_23.2 (%array_type.c13) [symbolic = %require_complete (constants.%require_complete.303)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc6_28.2 (%array_type.c13) [symbolic = %require_complete (constants.%require_complete.303)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%N.param_patt: %i32](%a.param_patt: @F.%array_type.loc6_23.2 (%array_type.c13)) -> %i32 { +// CHECK:STDOUT: fn[%N.param_patt: %i32](%a.param_patt: @F.%array_type.loc6_28.2 (%array_type.c13)) -> %i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %N.ref.loc6_42: %i32 = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N.51e)] -// CHECK:STDOUT: return %N.ref.loc6_42 +// CHECK:STDOUT: %N.ref.loc6_47: %i32 = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N.51e)] +// CHECK:STDOUT: return %N.ref.loc6_47 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1178,26 +1178,26 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1) +// CHECK:STDOUT: %.loc9_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_30.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_34.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_35.1: %tuple.type = tuple_literal (%.loc9_26.1, %.loc9_30.1, %.loc9_34.1) // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0 -// CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.2: ref %C = array_index %a.var, %int_0 +// CHECK:STDOUT: %.loc9_26.2: init %C = class_init (), %.loc9_35.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.3: init %C = converted %.loc9_26.1, %.loc9_26.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1 -// CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.4: ref %C = array_index %a.var, %int_1 +// CHECK:STDOUT: %.loc9_30.2: init %C = class_init (), %.loc9_35.4 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.5: init %C = converted %.loc9_30.1, %.loc9_30.2 [concrete = constants.%C.val] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] -// CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2 -// CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc9_35.6: ref %C = array_index %a.var, %int_2 +// CHECK:STDOUT: %.loc9_34.2: init %C = class_init (), %.loc9_35.6 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.7: init %C = converted %.loc9_34.1, %.loc9_34.2 [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc9_35.8: init %array_type.002 = array_init (%.loc9_35.3, %.loc9_35.5, %.loc9_35.7) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_35.1, %.loc9_35.8 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc9_3.2 -// CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [concrete = constants.%array_type.002] { +// CHECK:STDOUT: %.loc9_20: type = splice_block %array_type [concrete = constants.%array_type.002] { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [concrete = constants.%array_type.002] @@ -1213,7 +1213,7 @@ fn G() -> i32 { // CHECK:STDOUT: %N.patt.loc6_6.2 => constants.%N.51e // CHECK:STDOUT: %Convert.bound => constants.%Convert.bound // CHECK:STDOUT: %Convert.specific_fn => constants.%Convert.specific_fn -// CHECK:STDOUT: %int.convert_checked.loc6_22.2 => constants.%int.convert_checked -// CHECK:STDOUT: %array_type.loc6_23.2 => constants.%array_type.c13 +// CHECK:STDOUT: %int.convert_checked.loc6_27.2 => constants.%int.convert_checked +// CHECK:STDOUT: %array_type.loc6_28.2 => constants.%array_type.c13 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/eval/aggregate.carbon b/toolchain/check/testdata/eval/aggregate.carbon index 10501d7b1296..bfda06f3a886 100644 --- a/toolchain/check/testdata/eval/aggregate.carbon +++ b/toolchain/check/testdata/eval/aggregate.carbon @@ -12,9 +12,9 @@ var tuple_copy: (i32, i32) = (1, 2) as (i32, i32); var struct_copy: {.a: i32, .b: i32, .c: i32} = {.c = 3, .b = 2, .a = 1} as {.b: i32, .a: i32, .c: i32}; -var tuple_index: [i32; 1] = (0,) as [i32; (5, 7, 1, 9).2]; +var tuple_index: array(i32, 1) = (0,) as array(i32, (5, 7, 1, 9).2); -var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; +var struct_access: array(i32, 1) = (0,) as array(i32, {.a = 3, .b = 1}.b); // CHECK:STDOUT: --- aggregate.carbon // CHECK:STDOUT: @@ -117,7 +117,7 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: %.loc15_1: %array_type = var_pattern %tuple_index.patt // CHECK:STDOUT: } // CHECK:STDOUT: %tuple_index.var: ref %array_type = var tuple_index -// CHECK:STDOUT: %.loc15_25: type = splice_block %array_type.loc15 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc15_30: type = splice_block %array_type.loc15 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] @@ -129,7 +129,7 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: %.loc17_1: %array_type = var_pattern %struct_access.patt // CHECK:STDOUT: } // CHECK:STDOUT: %struct_access.var: ref %array_type = var struct_access -// CHECK:STDOUT: %.loc17_27: type = splice_block %array_type.loc17 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc17_32: type = splice_block %array_type.loc17 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1.loc17: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] @@ -215,55 +215,55 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: %.loc13_73.11: init %struct_type.a.b.c = struct_init (%.loc13_73.4, %.loc13_73.7, %.loc13_73.10) to file.%struct_copy.var [concrete = constants.%struct.cff] // CHECK:STDOUT: %.loc13_1: init %struct_type.a.b.c = converted %.loc13_73.1, %.loc13_73.11 [concrete = constants.%struct.cff] // CHECK:STDOUT: assign file.%struct_copy.var, %.loc13_1 -// CHECK:STDOUT: %int_0.loc15_30: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc15_32.1: %tuple.type.985 = tuple_literal (%int_0.loc15_30) +// CHECK:STDOUT: %int_0.loc15_35: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc15_37.1: %tuple.type.985 = tuple_literal (%int_0.loc15_35) // CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5] // CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete = constants.%int_7] // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9] -// CHECK:STDOUT: %.loc15_54.1: %tuple.type.d46 = tuple_literal (%int_5, %int_7, %int_1.loc15, %int_9) +// CHECK:STDOUT: %.loc15_64.1: %tuple.type.d46 = tuple_literal (%int_5, %int_7, %int_1.loc15, %int_9) // CHECK:STDOUT: %int_2.loc15: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] // CHECK:STDOUT: %tuple.loc15: %tuple.type.d46 = tuple_value (%int_5, %int_7, %int_1.loc15, %int_9) [concrete = constants.%tuple.869] -// CHECK:STDOUT: %.loc15_54.2: %tuple.type.d46 = converted %.loc15_54.1, %tuple.loc15 [concrete = constants.%tuple.869] -// CHECK:STDOUT: %tuple.elem2: Core.IntLiteral = tuple_access %.loc15_54.2, element2 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc15_64.2: %tuple.type.d46 = converted %.loc15_64.1, %tuple.loc15 [concrete = constants.%tuple.869] +// CHECK:STDOUT: %tuple.elem2: Core.IntLiteral = tuple_access %.loc15_64.2, element2 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %array_type.loc15: type = array_type %tuple.elem2, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: %impl.elem0.loc15: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc15: = bound_method %int_0.loc15_30, %impl.elem0.loc15 [concrete = constants.%Convert.bound.d04] +// CHECK:STDOUT: %bound_method.loc15: = bound_method %int_0.loc15_35, %impl.elem0.loc15 [concrete = constants.%Convert.bound.d04] // CHECK:STDOUT: %specific_fn.loc15: = specific_function %bound_method.loc15, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.d62] -// CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %specific_fn.loc15(%int_0.loc15_30) [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc15_32.2: init %i32 = converted %int_0.loc15_30, %int.convert_checked.loc15 [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %specific_fn.loc15(%int_0.loc15_35) [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc15_37.2: init %i32 = converted %int_0.loc15_35, %int.convert_checked.loc15 [concrete = constants.%int_0.6a9] // CHECK:STDOUT: %.loc15_1: ref %array_type = splice_block file.%tuple_index.var {} -// CHECK:STDOUT: %int_0.loc15_32: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc15_32.3: ref %i32 = array_index %.loc15_1, %int_0.loc15_32 -// CHECK:STDOUT: %.loc15_32.4: init %i32 = initialize_from %.loc15_32.2 to %.loc15_32.3 [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc15_32.5: init %array_type = array_init (%.loc15_32.4) to %.loc15_1 [concrete = constants.%array] -// CHECK:STDOUT: %.loc15_34: init %array_type = converted %.loc15_32.1, %.loc15_32.5 [concrete = constants.%array] -// CHECK:STDOUT: assign file.%tuple_index.var, %.loc15_34 -// CHECK:STDOUT: %int_0.loc17_32: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc17_34.1: %tuple.type.985 = tuple_literal (%int_0.loc17_32) +// CHECK:STDOUT: %int_0.loc15_37: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc15_37.3: ref %i32 = array_index %.loc15_1, %int_0.loc15_37 +// CHECK:STDOUT: %.loc15_37.4: init %i32 = initialize_from %.loc15_37.2 to %.loc15_37.3 [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc15_37.5: init %array_type = array_init (%.loc15_37.4) to %.loc15_1 [concrete = constants.%array] +// CHECK:STDOUT: %.loc15_39: init %array_type = converted %.loc15_37.1, %.loc15_37.5 [concrete = constants.%array] +// CHECK:STDOUT: assign file.%tuple_index.var, %.loc15_39 +// CHECK:STDOUT: %int_0.loc17_37: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc17_39.1: %tuple.type.985 = tuple_literal (%int_0.loc17_37) // CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_3.loc17: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] // CHECK:STDOUT: %int_1.loc17: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc17_60.1: %struct_type.a.b = struct_literal (%int_3.loc17, %int_1.loc17) +// CHECK:STDOUT: %.loc17_70.1: %struct_type.a.b = struct_literal (%int_3.loc17, %int_1.loc17) // CHECK:STDOUT: %struct.loc17: %struct_type.a.b = struct_value (%int_3.loc17, %int_1.loc17) [concrete = constants.%struct.a81] -// CHECK:STDOUT: %.loc17_60.2: %struct_type.a.b = converted %.loc17_60.1, %struct.loc17 [concrete = constants.%struct.a81] -// CHECK:STDOUT: %.loc17_61: Core.IntLiteral = struct_access %.loc17_60.2, element1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %array_type.loc17: type = array_type %.loc17_61, %i32 [concrete = constants.%array_type] +// CHECK:STDOUT: %.loc17_70.2: %struct_type.a.b = converted %.loc17_70.1, %struct.loc17 [concrete = constants.%struct.a81] +// CHECK:STDOUT: %.loc17_71: Core.IntLiteral = struct_access %.loc17_70.2, element1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %array_type.loc17: type = array_type %.loc17_71, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: %impl.elem0.loc17: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc17: = bound_method %int_0.loc17_32, %impl.elem0.loc17 [concrete = constants.%Convert.bound.d04] +// CHECK:STDOUT: %bound_method.loc17: = bound_method %int_0.loc17_37, %impl.elem0.loc17 [concrete = constants.%Convert.bound.d04] // CHECK:STDOUT: %specific_fn.loc17: = specific_function %bound_method.loc17, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.d62] -// CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %specific_fn.loc17(%int_0.loc17_32) [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc17_34.2: init %i32 = converted %int_0.loc17_32, %int.convert_checked.loc17 [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %specific_fn.loc17(%int_0.loc17_37) [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc17_39.2: init %i32 = converted %int_0.loc17_37, %int.convert_checked.loc17 [concrete = constants.%int_0.6a9] // CHECK:STDOUT: %.loc17_1: ref %array_type = splice_block file.%struct_access.var {} -// CHECK:STDOUT: %int_0.loc17_34: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc17_34.3: ref %i32 = array_index %.loc17_1, %int_0.loc17_34 -// CHECK:STDOUT: %.loc17_34.4: init %i32 = initialize_from %.loc17_34.2 to %.loc17_34.3 [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc17_34.5: init %array_type = array_init (%.loc17_34.4) to %.loc17_1 [concrete = constants.%array] -// CHECK:STDOUT: %.loc17_36: init %array_type = converted %.loc17_34.1, %.loc17_34.5 [concrete = constants.%array] -// CHECK:STDOUT: assign file.%struct_access.var, %.loc17_36 +// CHECK:STDOUT: %int_0.loc17_39: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc17_39.3: ref %i32 = array_index %.loc17_1, %int_0.loc17_39 +// CHECK:STDOUT: %.loc17_39.4: init %i32 = initialize_from %.loc17_39.2 to %.loc17_39.3 [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc17_39.5: init %array_type = array_init (%.loc17_39.4) to %.loc17_1 [concrete = constants.%array] +// CHECK:STDOUT: %.loc17_41: init %array_type = converted %.loc17_39.1, %.loc17_39.5 [concrete = constants.%array] +// CHECK:STDOUT: assign file.%struct_access.var, %.loc17_41 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/eval/fail_aggregate.carbon b/toolchain/check/testdata/eval/fail_aggregate.carbon index 4f0435ae2395..19e118429f9c 100644 --- a/toolchain/check/testdata/eval/fail_aggregate.carbon +++ b/toolchain/check/testdata/eval/fail_aggregate.carbon @@ -10,11 +10,11 @@ // TODO: This creates an array temporary, which we don't yet support evaluating. -// CHECK:STDERR: fail_aggregate.carbon:[[@LINE+4]]:43: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_aggregate.carbon:[[@LINE+4]]:53: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: var array_index: array(i32, 1) = (0,) as array(i32, ((5, 7, 1, 9) as array(i32, 4))[2]); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]]; +var array_index: array(i32, 1) = (0,) as array(i32, ((5, 7, 1, 9) as array(i32, 4))[2]); // CHECK:STDOUT: --- fail_aggregate.carbon // CHECK:STDOUT: @@ -78,7 +78,7 @@ var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]]; // CHECK:STDOUT: %.loc17_1: %array_type.0cb = var_pattern %array_index.patt // CHECK:STDOUT: } // CHECK:STDOUT: %array_index.var: ref %array_type.0cb = var array_index -// CHECK:STDOUT: %.loc17_25: type = splice_block %array_type [concrete = constants.%array_type.0cb] { +// CHECK:STDOUT: %.loc17_30: type = splice_block %array_type [concrete = constants.%array_type.0cb] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] @@ -89,66 +89,66 @@ var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %int_0.loc17_30: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc17_32: %tuple.type.985 = tuple_literal (%int_0.loc17_30) -// CHECK:STDOUT: %int_32.loc17_38: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc17_38: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %int_0.loc17_35: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] +// CHECK:STDOUT: %.loc17_37: %tuple.type.985 = tuple_literal (%int_0.loc17_35) +// CHECK:STDOUT: %int_32.loc17_48: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc17_48: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] // CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f] -// CHECK:STDOUT: %int_1.loc17_51: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_1.loc17_61: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9.988] -// CHECK:STDOUT: %.loc17_55.1: %tuple.type.d46 = tuple_literal (%int_5, %int_7, %int_1.loc17_51, %int_9) -// CHECK:STDOUT: %int_32.loc17_61: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc17_61: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %.loc17_65.1: %tuple.type.d46 = tuple_literal (%int_5, %int_7, %int_1.loc17_61, %int_9) +// CHECK:STDOUT: %int_32.loc17_76: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc17_76: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4] // CHECK:STDOUT: %array_type: type = array_type %int_4, %i32 [concrete = constants.%array_type.f32] -// CHECK:STDOUT: %impl.elem0.loc17_55.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc17_55.1: = bound_method %int_5, %impl.elem0.loc17_55.1 [concrete = constants.%Convert.bound.4e6] -// CHECK:STDOUT: %specific_fn.loc17_55.1: = specific_function %bound_method.loc17_55.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.ba9] -// CHECK:STDOUT: %int.convert_checked.loc17_55.1: init %i32 = call %specific_fn.loc17_55.1(%int_5) [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc17_55.2: init %i32 = converted %int_5, %int.convert_checked.loc17_55.1 [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc17_55.3: ref %array_type.f32 = temporary_storage -// CHECK:STDOUT: %int_0.loc17_55: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc17_55.4: ref %i32 = array_index %.loc17_55.3, %int_0.loc17_55 -// CHECK:STDOUT: %.loc17_55.5: init %i32 = initialize_from %.loc17_55.2 to %.loc17_55.4 [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %impl.elem0.loc17_55.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc17_55.2: = bound_method %int_7, %impl.elem0.loc17_55.2 [concrete = constants.%Convert.bound.208] -// CHECK:STDOUT: %specific_fn.loc17_55.2: = specific_function %bound_method.loc17_55.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.c12] -// CHECK:STDOUT: %int.convert_checked.loc17_55.2: init %i32 = call %specific_fn.loc17_55.2(%int_7) [concrete = constants.%int_7.0b1] -// CHECK:STDOUT: %.loc17_55.6: init %i32 = converted %int_7, %int.convert_checked.loc17_55.2 [concrete = constants.%int_7.0b1] -// CHECK:STDOUT: %int_1.loc17_55: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc17_55.7: ref %i32 = array_index %.loc17_55.3, %int_1.loc17_55 -// CHECK:STDOUT: %.loc17_55.8: init %i32 = initialize_from %.loc17_55.6 to %.loc17_55.7 [concrete = constants.%int_7.0b1] -// CHECK:STDOUT: %impl.elem0.loc17_55.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc17_55.3: = bound_method %int_1.loc17_51, %impl.elem0.loc17_55.3 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc17_55.3: = specific_function %bound_method.loc17_55.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc17_55.3: init %i32 = call %specific_fn.loc17_55.3(%int_1.loc17_51) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc17_55.9: init %i32 = converted %int_1.loc17_51, %int.convert_checked.loc17_55.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %int_2.loc17_55: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc17_55.10: ref %i32 = array_index %.loc17_55.3, %int_2.loc17_55 -// CHECK:STDOUT: %.loc17_55.11: init %i32 = initialize_from %.loc17_55.9 to %.loc17_55.10 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc17_55.4: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc17_55.4: = bound_method %int_9, %impl.elem0.loc17_55.4 [concrete = constants.%Convert.bound.9e2] -// CHECK:STDOUT: %specific_fn.loc17_55.4: = specific_function %bound_method.loc17_55.4, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b02] -// CHECK:STDOUT: %int.convert_checked.loc17_55.4: init %i32 = call %specific_fn.loc17_55.4(%int_9) [concrete = constants.%int_9.f88] -// CHECK:STDOUT: %.loc17_55.12: init %i32 = converted %int_9, %int.convert_checked.loc17_55.4 [concrete = constants.%int_9.f88] +// CHECK:STDOUT: %impl.elem0.loc17_65.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc17_65.1: = bound_method %int_5, %impl.elem0.loc17_65.1 [concrete = constants.%Convert.bound.4e6] +// CHECK:STDOUT: %specific_fn.loc17_65.1: = specific_function %bound_method.loc17_65.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.ba9] +// CHECK:STDOUT: %int.convert_checked.loc17_65.1: init %i32 = call %specific_fn.loc17_65.1(%int_5) [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc17_65.2: init %i32 = converted %int_5, %int.convert_checked.loc17_65.1 [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc17_65.3: ref %array_type.f32 = temporary_storage +// CHECK:STDOUT: %int_0.loc17_65: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] +// CHECK:STDOUT: %.loc17_65.4: ref %i32 = array_index %.loc17_65.3, %int_0.loc17_65 +// CHECK:STDOUT: %.loc17_65.5: init %i32 = initialize_from %.loc17_65.2 to %.loc17_65.4 [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %impl.elem0.loc17_65.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc17_65.2: = bound_method %int_7, %impl.elem0.loc17_65.2 [concrete = constants.%Convert.bound.208] +// CHECK:STDOUT: %specific_fn.loc17_65.2: = specific_function %bound_method.loc17_65.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.c12] +// CHECK:STDOUT: %int.convert_checked.loc17_65.2: init %i32 = call %specific_fn.loc17_65.2(%int_7) [concrete = constants.%int_7.0b1] +// CHECK:STDOUT: %.loc17_65.6: init %i32 = converted %int_7, %int.convert_checked.loc17_65.2 [concrete = constants.%int_7.0b1] +// CHECK:STDOUT: %int_1.loc17_65: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc17_65.7: ref %i32 = array_index %.loc17_65.3, %int_1.loc17_65 +// CHECK:STDOUT: %.loc17_65.8: init %i32 = initialize_from %.loc17_65.6 to %.loc17_65.7 [concrete = constants.%int_7.0b1] +// CHECK:STDOUT: %impl.elem0.loc17_65.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc17_65.3: = bound_method %int_1.loc17_61, %impl.elem0.loc17_65.3 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc17_65.3: = specific_function %bound_method.loc17_65.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc17_65.3: init %i32 = call %specific_fn.loc17_65.3(%int_1.loc17_61) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc17_65.9: init %i32 = converted %int_1.loc17_61, %int.convert_checked.loc17_65.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %int_2.loc17_65: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc17_65.10: ref %i32 = array_index %.loc17_65.3, %int_2.loc17_65 +// CHECK:STDOUT: %.loc17_65.11: init %i32 = initialize_from %.loc17_65.9 to %.loc17_65.10 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc17_65.4: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc17_65.4: = bound_method %int_9, %impl.elem0.loc17_65.4 [concrete = constants.%Convert.bound.9e2] +// CHECK:STDOUT: %specific_fn.loc17_65.4: = specific_function %bound_method.loc17_65.4, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b02] +// CHECK:STDOUT: %int.convert_checked.loc17_65.4: init %i32 = call %specific_fn.loc17_65.4(%int_9) [concrete = constants.%int_9.f88] +// CHECK:STDOUT: %.loc17_65.12: init %i32 = converted %int_9, %int.convert_checked.loc17_65.4 [concrete = constants.%int_9.f88] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3] -// CHECK:STDOUT: %.loc17_55.13: ref %i32 = array_index %.loc17_55.3, %int_3 -// CHECK:STDOUT: %.loc17_55.14: init %i32 = initialize_from %.loc17_55.12 to %.loc17_55.13 [concrete = constants.%int_9.f88] -// CHECK:STDOUT: %.loc17_55.15: init %array_type.f32 = array_init (%.loc17_55.5, %.loc17_55.8, %.loc17_55.11, %.loc17_55.14) to %.loc17_55.3 [concrete = constants.%array] -// CHECK:STDOUT: %.loc17_57.1: init %array_type.f32 = converted %.loc17_55.1, %.loc17_55.15 [concrete = constants.%array] -// CHECK:STDOUT: %int_2.loc17_70: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc17_57.2: ref %array_type.f32 = temporary %.loc17_55.3, %.loc17_57.1 -// CHECK:STDOUT: %int_32.loc17_71: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc17_71: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %impl.elem0.loc17_70: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc17_70: = bound_method %int_2.loc17_70, %impl.elem0.loc17_70 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc17_70: = specific_function %bound_method.loc17_70, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc17_70: init %i32 = call %specific_fn.loc17_70(%int_2.loc17_70) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc17_70.1: %i32 = value_of_initializer %int.convert_checked.loc17_70 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc17_70.2: %i32 = converted %int_2.loc17_70, %.loc17_70.1 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc17_71.1: ref %i32 = array_index %.loc17_57.2, %.loc17_70.2 -// CHECK:STDOUT: %.loc17_71.2: %i32 = bind_value %.loc17_71.1 +// CHECK:STDOUT: %.loc17_65.13: ref %i32 = array_index %.loc17_65.3, %int_3 +// CHECK:STDOUT: %.loc17_65.14: init %i32 = initialize_from %.loc17_65.12 to %.loc17_65.13 [concrete = constants.%int_9.f88] +// CHECK:STDOUT: %.loc17_65.15: init %array_type.f32 = array_init (%.loc17_65.5, %.loc17_65.8, %.loc17_65.11, %.loc17_65.14) to %.loc17_65.3 [concrete = constants.%array] +// CHECK:STDOUT: %.loc17_67.1: init %array_type.f32 = converted %.loc17_65.1, %.loc17_65.15 [concrete = constants.%array] +// CHECK:STDOUT: %int_2.loc17_85: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc17_67.2: ref %array_type.f32 = temporary %.loc17_65.3, %.loc17_67.1 +// CHECK:STDOUT: %int_32.loc17_86: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc17_86: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %impl.elem0.loc17_85: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc17_85: = bound_method %int_2.loc17_85, %impl.elem0.loc17_85 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc17_85: = specific_function %bound_method.loc17_85, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc17_85: init %i32 = call %specific_fn.loc17_85(%int_2.loc17_85) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc17_85.1: %i32 = value_of_initializer %int.convert_checked.loc17_85 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc17_85.2: %i32 = converted %int_2.loc17_85, %.loc17_85.1 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc17_86.1: ref %i32 = array_index %.loc17_67.2, %.loc17_85.2 +// CHECK:STDOUT: %.loc17_86.2: %i32 = bind_value %.loc17_86.1 // CHECK:STDOUT: assign file.%array_index.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/eval/symbolic.carbon b/toolchain/check/testdata/eval/symbolic.carbon index 2122e0507214..38eb9e6b065d 100644 --- a/toolchain/check/testdata/eval/symbolic.carbon +++ b/toolchain/check/testdata/eval/symbolic.carbon @@ -12,11 +12,11 @@ fn F(T:! type) { var u: (T*, const T); var v: {.a: T}; - var w: [T; 5]; + var w: array(T, 5); } fn G(N:! i32) { - var k: [i32; N]; + var k: array(i32, N); } // CHECK:STDOUT: --- symbolic.carbon @@ -103,8 +103,8 @@ fn G(N:! i32) { // CHECK:STDOUT: %require_complete.loc13: = require_complete_type @F.%tuple.type (%tuple.type.4f2) [symbolic = %require_complete.loc13 (constants.%require_complete.155)] // CHECK:STDOUT: %struct_type.a.loc14_16.2: type = struct_type {.a: @F.%T.loc12_6.2 (%T)} [symbolic = %struct_type.a.loc14_16.2 (constants.%struct_type.a)] // CHECK:STDOUT: %require_complete.loc14: = require_complete_type @F.%struct_type.a.loc14_16.2 (%struct_type.a) [symbolic = %require_complete.loc14 (constants.%require_complete.28a)] -// CHECK:STDOUT: %array_type.loc15_15.2: type = array_type constants.%int_5, @F.%T.loc12_6.2 (%T) [symbolic = %array_type.loc15_15.2 (constants.%array_type.ec2)] -// CHECK:STDOUT: %require_complete.loc15: = require_complete_type @F.%array_type.loc15_15.2 (%array_type.ec2) [symbolic = %require_complete.loc15 (constants.%require_complete.fe1)] +// CHECK:STDOUT: %array_type.loc15_20.2: type = array_type constants.%int_5, @F.%T.loc12_6.2 (%T) [symbolic = %array_type.loc15_20.2 (constants.%array_type.ec2)] +// CHECK:STDOUT: %require_complete.loc15: = require_complete_type @F.%array_type.loc15_20.2 (%array_type.ec2) [symbolic = %require_complete.loc15 (constants.%require_complete.fe1)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type) { // CHECK:STDOUT: !entry: @@ -133,16 +133,16 @@ fn G(N:! i32) { // CHECK:STDOUT: } // CHECK:STDOUT: %v: ref @F.%struct_type.a.loc14_16.2 (%struct_type.a) = bind_name v, %v.var // CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %w.patt: @F.%array_type.loc15_15.2 (%array_type.ec2) = binding_pattern w -// CHECK:STDOUT: %.loc15_3: @F.%array_type.loc15_15.2 (%array_type.ec2) = var_pattern %w.patt +// CHECK:STDOUT: %w.patt: @F.%array_type.loc15_20.2 (%array_type.ec2) = binding_pattern w +// CHECK:STDOUT: %.loc15_3: @F.%array_type.loc15_20.2 (%array_type.ec2) = var_pattern %w.patt // CHECK:STDOUT: } -// CHECK:STDOUT: %w.var: ref @F.%array_type.loc15_15.2 (%array_type.ec2) = var w -// CHECK:STDOUT: %.loc15_15: type = splice_block %array_type.loc15_15.1 [symbolic = %array_type.loc15_15.2 (constants.%array_type.ec2)] { +// CHECK:STDOUT: %w.var: ref @F.%array_type.loc15_20.2 (%array_type.ec2) = var w +// CHECK:STDOUT: %.loc15_20: type = splice_block %array_type.loc15_20.1 [symbolic = %array_type.loc15_20.2 (constants.%array_type.ec2)] { // CHECK:STDOUT: %T.ref.loc15: type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5] -// CHECK:STDOUT: %array_type.loc15_15.1: type = array_type %int_5, %T [symbolic = %array_type.loc15_15.2 (constants.%array_type.ec2)] +// CHECK:STDOUT: %array_type.loc15_20.1: type = array_type %int_5, %T [symbolic = %array_type.loc15_20.2 (constants.%array_type.ec2)] // CHECK:STDOUT: } -// CHECK:STDOUT: %w: ref @F.%array_type.loc15_15.2 (%array_type.ec2) = bind_name w, %w.var +// CHECK:STDOUT: %w: ref @F.%array_type.loc15_20.2 (%array_type.ec2) = bind_name w, %w.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -154,30 +154,30 @@ fn G(N:! i32) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %Convert.bound: = bound_method %N.loc18_6.2, constants.%Convert.960 [symbolic = %Convert.bound (constants.%Convert.bound)] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked.loc19_16.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc18_6.2) [symbolic = %int.convert_checked.loc19_16.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc19_17.2: type = array_type %int.convert_checked.loc19_16.2, %i32 [symbolic = %array_type.loc19_17.2 (constants.%array_type.b04)] -// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type.loc19_17.2 (%array_type.b04) [symbolic = %require_complete (constants.%require_complete.9dc)] +// CHECK:STDOUT: %int.convert_checked.loc19_21.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc18_6.2) [symbolic = %int.convert_checked.loc19_21.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc19_22.2: type = array_type %int.convert_checked.loc19_21.2, %i32 [symbolic = %array_type.loc19_22.2 (constants.%array_type.b04)] +// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type.loc19_22.2 (%array_type.b04) [symbolic = %require_complete (constants.%require_complete.9dc)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%N.param_patt: %i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %k.patt: @G.%array_type.loc19_17.2 (%array_type.b04) = binding_pattern k -// CHECK:STDOUT: %.loc19_3: @G.%array_type.loc19_17.2 (%array_type.b04) = var_pattern %k.patt +// CHECK:STDOUT: %k.patt: @G.%array_type.loc19_22.2 (%array_type.b04) = binding_pattern k +// CHECK:STDOUT: %.loc19_3: @G.%array_type.loc19_22.2 (%array_type.b04) = var_pattern %k.patt // CHECK:STDOUT: } -// CHECK:STDOUT: %k.var: ref @G.%array_type.loc19_17.2 (%array_type.b04) = var k -// CHECK:STDOUT: %.loc19_17: type = splice_block %array_type.loc19_17.1 [symbolic = %array_type.loc19_17.2 (constants.%array_type.b04)] { +// CHECK:STDOUT: %k.var: ref @G.%array_type.loc19_22.2 (%array_type.b04) = var k +// CHECK:STDOUT: %.loc19_22: type = splice_block %array_type.loc19_22.1 [symbolic = %array_type.loc19_22.2 (constants.%array_type.b04)] { // CHECK:STDOUT: %int_32.loc19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc18_6.1 [symbolic = %N.loc18_6.2 (constants.%N.51e)] // CHECK:STDOUT: %impl.elem0: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] // CHECK:STDOUT: %bound_method: = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound)] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked.loc19_16.1: init Core.IntLiteral = call %specific_fn(%N.ref) [symbolic = %int.convert_checked.loc19_16.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc19_16.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc19_16.1 [symbolic = %int.convert_checked.loc19_16.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc19_16.2: Core.IntLiteral = converted %N.ref, %.loc19_16.1 [symbolic = %int.convert_checked.loc19_16.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc19_17.1: type = array_type %.loc19_16.2, %i32 [symbolic = %array_type.loc19_17.2 (constants.%array_type.b04)] +// CHECK:STDOUT: %int.convert_checked.loc19_21.1: init Core.IntLiteral = call %specific_fn(%N.ref) [symbolic = %int.convert_checked.loc19_21.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc19_21.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc19_21.1 [symbolic = %int.convert_checked.loc19_21.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc19_21.2: Core.IntLiteral = converted %N.ref, %.loc19_21.1 [symbolic = %int.convert_checked.loc19_21.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc19_22.1: type = array_type %.loc19_21.2, %i32 [symbolic = %array_type.loc19_22.2 (constants.%array_type.b04)] // CHECK:STDOUT: } -// CHECK:STDOUT: %k: ref @G.%array_type.loc19_17.2 (%array_type.b04) = bind_name k, %k.var +// CHECK:STDOUT: %k: ref @G.%array_type.loc19_22.2 (%array_type.b04) = bind_name k, %k.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/builtin/call.carbon b/toolchain/check/testdata/function/builtin/call.carbon index dd81153bd79f..5a7e368a2c50 100644 --- a/toolchain/check/testdata/function/builtin/call.carbon +++ b/toolchain/check/testdata/function/builtin/call.carbon @@ -10,7 +10,7 @@ fn Add(a: i32, b: i32) -> i32 = "int.sadd"; -var arr: [i32; Add(1, 2)]; +var arr: array(i32, Add(1, 2)); fn RuntimeCall(a: i32, b: i32) -> i32 { return Add(a, b); @@ -101,34 +101,34 @@ fn RuntimeCall(a: i32, b: i32) -> i32 { // CHECK:STDOUT: %.loc13_1: %array_type = var_pattern %arr.patt // CHECK:STDOUT: } // CHECK:STDOUT: %arr.var: ref %array_type = var arr -// CHECK:STDOUT: %.loc13_25: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc13_30: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %Add.ref: %Add.type.b1f = name_ref Add, %Add.decl [concrete = constants.%Add] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %impl.elem0.loc13_20: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc13_20: = bound_method %int_1, %impl.elem0.loc13_20 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc13_20: = specific_function %bound_method.loc13_20, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc13_20: init %i32 = call %specific_fn.loc13_20(%int_1) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc13_20.1: %i32 = value_of_initializer %int.convert_checked.loc13_20 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc13_20.2: %i32 = converted %int_1, %.loc13_20.1 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc13_23: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc13_23: = bound_method %int_2, %impl.elem0.loc13_23 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc13_23: = specific_function %bound_method.loc13_23, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc13_23: init %i32 = call %specific_fn.loc13_23(%int_2) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_23.1: %i32 = value_of_initializer %int.convert_checked.loc13_23 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_23.2: %i32 = converted %int_2, %.loc13_23.1 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int.sadd: init %i32 = call %Add.ref(%.loc13_20.2, %.loc13_23.2) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %impl.elem0.loc13_24: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] -// CHECK:STDOUT: %bound_method.loc13_24: = bound_method %int.sadd, %impl.elem0.loc13_24 [concrete = constants.%Convert.bound.2d6] -// CHECK:STDOUT: %specific_fn.loc13_24: = specific_function %bound_method.loc13_24, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.377] -// CHECK:STDOUT: %.loc13_24.1: %i32 = value_of_initializer %int.sadd [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc13_24.2: %i32 = converted %int.sadd, %.loc13_24.1 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int.convert_checked.loc13_24: init Core.IntLiteral = call %specific_fn.loc13_24(%.loc13_24.2) [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc13_24.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc13_24 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc13_24.4: Core.IntLiteral = converted %int.sadd, %.loc13_24.3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type: type = array_type %.loc13_24.4, %i32 [concrete = constants.%array_type] +// CHECK:STDOUT: %impl.elem0.loc13_25: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc13_25: = bound_method %int_1, %impl.elem0.loc13_25 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc13_25: = specific_function %bound_method.loc13_25, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc13_25: init %i32 = call %specific_fn.loc13_25(%int_1) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_25.1: %i32 = value_of_initializer %int.convert_checked.loc13_25 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_25.2: %i32 = converted %int_1, %.loc13_25.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc13_28: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc13_28: = bound_method %int_2, %impl.elem0.loc13_28 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc13_28: = specific_function %bound_method.loc13_28, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc13_28: init %i32 = call %specific_fn.loc13_28(%int_2) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_28.1: %i32 = value_of_initializer %int.convert_checked.loc13_28 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_28.2: %i32 = converted %int_2, %.loc13_28.1 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int.sadd: init %i32 = call %Add.ref(%.loc13_25.2, %.loc13_28.2) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %impl.elem0.loc13_29: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] +// CHECK:STDOUT: %bound_method.loc13_29: = bound_method %int.sadd, %impl.elem0.loc13_29 [concrete = constants.%Convert.bound.2d6] +// CHECK:STDOUT: %specific_fn.loc13_29: = specific_function %bound_method.loc13_29, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.377] +// CHECK:STDOUT: %.loc13_29.1: %i32 = value_of_initializer %int.sadd [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc13_29.2: %i32 = converted %int.sadd, %.loc13_29.1 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc13_29: init Core.IntLiteral = call %specific_fn.loc13_29(%.loc13_29.2) [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc13_29.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc13_29 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc13_29.4: Core.IntLiteral = converted %int.sadd, %.loc13_29.3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %.loc13_29.4, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var // CHECK:STDOUT: %RuntimeCall.decl: %RuntimeCall.type = fn_decl @RuntimeCall [concrete = constants.%RuntimeCall] { diff --git a/toolchain/check/testdata/function/builtin/method.carbon b/toolchain/check/testdata/function/builtin/method.carbon index 63a6f7c9313d..40505171ab0a 100644 --- a/toolchain/check/testdata/function/builtin/method.carbon +++ b/toolchain/check/testdata/function/builtin/method.carbon @@ -16,7 +16,7 @@ impl i32 as I { fn F[self: i32](other: i32) -> i32 = "int.sadd"; } -var arr: [i32; (1 as i32).(I.F)(2)]; +var arr: array(i32, (1 as i32).(I.F)(2)); // CHECK:STDOUT: --- method.carbon // CHECK:STDOUT: @@ -101,39 +101,39 @@ var arr: [i32; (1 as i32).(I.F)(2)]; // CHECK:STDOUT: %.loc19_1: %array_type = var_pattern %arr.patt // CHECK:STDOUT: } // CHECK:STDOUT: %arr.var: ref %array_type = var arr -// CHECK:STDOUT: %.loc19_35: type = splice_block %array_type [concrete = constants.%array_type] { -// CHECK:STDOUT: %int_32.loc19_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc19_11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %.loc19_40: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc19_16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc19_16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_32.loc19_22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc19_22: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %impl.elem0.loc19_19: %.214 = impl_witness_access constants.%impl_witness.882, element0 [concrete = constants.%Convert.197] -// CHECK:STDOUT: %bound_method.loc19_19: = bound_method %int_1, %impl.elem0.loc19_19 [concrete = constants.%Convert.bound.c1b] -// CHECK:STDOUT: %specific_fn.loc19_19: = specific_function %bound_method.loc19_19, @Convert.5(constants.%int_32) [concrete = constants.%Convert.specific_fn.f9a] -// CHECK:STDOUT: %int.convert_checked.loc19_19: init %i32 = call %specific_fn.loc19_19(%int_1) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc19_19.1: %i32 = value_of_initializer %int.convert_checked.loc19_19 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc19_19.2: %i32 = converted %int_1, %.loc19_19.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %int_32.loc19_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc19_27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %impl.elem0.loc19_24: %.214 = impl_witness_access constants.%impl_witness.882, element0 [concrete = constants.%Convert.197] +// CHECK:STDOUT: %bound_method.loc19_24: = bound_method %int_1, %impl.elem0.loc19_24 [concrete = constants.%Convert.bound.c1b] +// CHECK:STDOUT: %specific_fn.loc19_24: = specific_function %bound_method.loc19_24, @Convert.5(constants.%int_32) [concrete = constants.%Convert.specific_fn.f9a] +// CHECK:STDOUT: %int.convert_checked.loc19_24: init %i32 = call %specific_fn.loc19_24(%int_1) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc19_24.1: %i32 = value_of_initializer %int.convert_checked.loc19_24 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc19_24.2: %i32 = converted %int_1, %.loc19_24.1 [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [concrete = constants.%I.type] // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.%assoc0 [concrete = constants.%assoc0.a5e] -// CHECK:STDOUT: %impl.elem0.loc19_26: %.c3e = impl_witness_access constants.%impl_witness.da7, element0 [concrete = constants.%F.9ec] -// CHECK:STDOUT: %bound_method.loc19_26: = bound_method %.loc19_19.2, %impl.elem0.loc19_26 [concrete = constants.%F.bound] +// CHECK:STDOUT: %impl.elem0.loc19_31: %.c3e = impl_witness_access constants.%impl_witness.da7, element0 [concrete = constants.%F.9ec] +// CHECK:STDOUT: %bound_method.loc19_31: = bound_method %.loc19_24.2, %impl.elem0.loc19_31 [concrete = constants.%F.bound] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %impl.elem0.loc19_33: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc19_33: = bound_method %int_2, %impl.elem0.loc19_33 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc19_33: = specific_function %bound_method.loc19_33, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc19_33: init %i32 = call %specific_fn.loc19_33(%int_2) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc19_33.1: %i32 = value_of_initializer %int.convert_checked.loc19_33 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc19_33.2: %i32 = converted %int_2, %.loc19_33.1 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int.sadd: init %i32 = call %bound_method.loc19_26(%.loc19_19.2, %.loc19_33.2) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %impl.elem0.loc19_34: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] -// CHECK:STDOUT: %bound_method.loc19_34: = bound_method %int.sadd, %impl.elem0.loc19_34 [concrete = constants.%Convert.bound.2d6] -// CHECK:STDOUT: %specific_fn.loc19_34: = specific_function %bound_method.loc19_34, @Convert.4(constants.%int_32) [concrete = constants.%Convert.specific_fn.377] -// CHECK:STDOUT: %.loc19_34.1: %i32 = value_of_initializer %int.sadd [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc19_34.2: %i32 = converted %int.sadd, %.loc19_34.1 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int.convert_checked.loc19_34: init Core.IntLiteral = call %specific_fn.loc19_34(%.loc19_34.2) [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc19_34.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc19_34 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc19_34.4: Core.IntLiteral = converted %int.sadd, %.loc19_34.3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type: type = array_type %.loc19_34.4, %i32 [concrete = constants.%array_type] +// CHECK:STDOUT: %impl.elem0.loc19_38: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc19_38: = bound_method %int_2, %impl.elem0.loc19_38 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc19_38: = specific_function %bound_method.loc19_38, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc19_38: init %i32 = call %specific_fn.loc19_38(%int_2) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc19_38.1: %i32 = value_of_initializer %int.convert_checked.loc19_38 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc19_38.2: %i32 = converted %int_2, %.loc19_38.1 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int.sadd: init %i32 = call %bound_method.loc19_31(%.loc19_24.2, %.loc19_38.2) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %impl.elem0.loc19_39: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] +// CHECK:STDOUT: %bound_method.loc19_39: = bound_method %int.sadd, %impl.elem0.loc19_39 [concrete = constants.%Convert.bound.2d6] +// CHECK:STDOUT: %specific_fn.loc19_39: = specific_function %bound_method.loc19_39, @Convert.4(constants.%int_32) [concrete = constants.%Convert.specific_fn.377] +// CHECK:STDOUT: %.loc19_39.1: %i32 = value_of_initializer %int.sadd [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc19_39.2: %i32 = converted %int.sadd, %.loc19_39.1 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc19_39: init Core.IntLiteral = call %specific_fn.loc19_39(%.loc19_39.2) [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc19_39.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc19_39 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc19_39.4: Core.IntLiteral = converted %int.sadd, %.loc19_39.3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %.loc19_39.4, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon b/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon index 168945f036aa..dacbe3f1669f 100644 --- a/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon +++ b/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon @@ -47,7 +47,7 @@ impl i32 as ImplicitAs(IntLiteral()) { import Core; -var arr: [i32; (1 as i32) + (2 as i32)] = (3, 4, (3 as i32) + (4 as i32)); +var arr: array(i32, (1 as i32) + (2 as i32)) = (3, 4, (3 as i32) + (4 as i32)); // CHECK:STDOUT: --- core.carbon // CHECK:STDOUT: @@ -711,42 +711,42 @@ var arr: [i32; (1 as i32) + (2 as i32)] = (3, 4, (3 as i32) + (4 as i32)); // CHECK:STDOUT: %.loc4_1: %array_type = var_pattern %arr.patt // CHECK:STDOUT: } // CHECK:STDOUT: %arr.var: ref %array_type = var arr -// CHECK:STDOUT: %.loc4_39: type = splice_block %array_type [concrete = constants.%array_type] { -// CHECK:STDOUT: %int_32.loc4_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %int.make_type_signed.loc4_11: init type = call constants.%Int(%int_32.loc4_11) [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_44: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc4_16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed.loc4_16: init type = call constants.%Int(%int_32.loc4_16) [concrete = constants.%i32.builtin] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_32.loc4_22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %int.make_type_signed.loc4_22: init type = call constants.%Int(%int_32.loc4_22) [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_22.1: type = value_of_initializer %int.make_type_signed.loc4_22 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_22.2: type = converted %int.make_type_signed.loc4_22, %.loc4_22.1 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %impl.elem0.loc4_19: %.dc4 = impl_witness_access constants.%impl_witness.d9b, element0 [concrete = constants.%Convert.5bc] -// CHECK:STDOUT: %bound_method.loc4_19: = bound_method %int_1, %impl.elem0.loc4_19 [concrete = constants.%Convert.bound.b34] -// CHECK:STDOUT: %int.convert_checked.loc4_19: init %i32.builtin = call %bound_method.loc4_19(%int_1) [concrete = constants.%int_1.f38] -// CHECK:STDOUT: %.loc4_19.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_19 [concrete = constants.%int_1.f38] -// CHECK:STDOUT: %.loc4_19.2: %i32.builtin = converted %int_1, %.loc4_19.1 [concrete = constants.%int_1.f38] +// CHECK:STDOUT: %int_32.loc4_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed.loc4_27: init type = call constants.%Int(%int_32.loc4_27) [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_signed.loc4_27 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_signed.loc4_27, %.loc4_27.1 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %impl.elem0.loc4_24: %.dc4 = impl_witness_access constants.%impl_witness.d9b, element0 [concrete = constants.%Convert.5bc] +// CHECK:STDOUT: %bound_method.loc4_24: = bound_method %int_1, %impl.elem0.loc4_24 [concrete = constants.%Convert.bound.b34] +// CHECK:STDOUT: %int.convert_checked.loc4_24: init %i32.builtin = call %bound_method.loc4_24(%int_1) [concrete = constants.%int_1.f38] +// CHECK:STDOUT: %.loc4_24.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_24 [concrete = constants.%int_1.f38] +// CHECK:STDOUT: %.loc4_24.2: %i32.builtin = converted %int_1, %.loc4_24.1 [concrete = constants.%int_1.f38] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %int_32.loc4_35: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %int.make_type_signed.loc4_35: init type = call constants.%Int(%int_32.loc4_35) [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_35.1: type = value_of_initializer %int.make_type_signed.loc4_35 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_35.2: type = converted %int.make_type_signed.loc4_35, %.loc4_35.1 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %impl.elem0.loc4_32: %.dc4 = impl_witness_access constants.%impl_witness.d9b, element0 [concrete = constants.%Convert.5bc] -// CHECK:STDOUT: %bound_method.loc4_32: = bound_method %int_2, %impl.elem0.loc4_32 [concrete = constants.%Convert.bound.324] -// CHECK:STDOUT: %int.convert_checked.loc4_32: init %i32.builtin = call %bound_method.loc4_32(%int_2) [concrete = constants.%int_2.5a1] -// CHECK:STDOUT: %.loc4_32.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_32 [concrete = constants.%int_2.5a1] -// CHECK:STDOUT: %.loc4_32.2: %i32.builtin = converted %int_2, %.loc4_32.1 [concrete = constants.%int_2.5a1] -// CHECK:STDOUT: %impl.elem0.loc4_27.1: %.7c2 = impl_witness_access constants.%impl_witness.bd0, element0 [concrete = constants.%Op.0e2] -// CHECK:STDOUT: %bound_method.loc4_27.1: = bound_method %.loc4_19.2, %impl.elem0.loc4_27.1 [concrete = constants.%Op.bound.393] -// CHECK:STDOUT: %int.sadd: init %i32.builtin = call %bound_method.loc4_27.1(%.loc4_19.2, %.loc4_32.2) [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_signed.loc4_11 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_signed.loc4_11, %.loc4_11.1 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %impl.elem0.loc4_27.2: %.38f = impl_witness_access constants.%impl_witness.8f3, element0 [concrete = constants.%Convert.b32] -// CHECK:STDOUT: %bound_method.loc4_27.2: = bound_method %int.sadd, %impl.elem0.loc4_27.2 [concrete = constants.%Convert.bound.65a] -// CHECK:STDOUT: %.loc4_27.1: %i32.builtin = value_of_initializer %int.sadd [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_27.2: %i32.builtin = converted %int.sadd, %.loc4_27.1 [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %int.convert_checked.loc4_27: init Core.IntLiteral = call %bound_method.loc4_27.2(%.loc4_27.2) [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc4_27.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc4_27 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc4_27.4: Core.IntLiteral = converted %int.sadd, %.loc4_27.3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type: type = array_type %.loc4_27.4, %i32.builtin [concrete = constants.%array_type] +// CHECK:STDOUT: %int_32.loc4_40: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed.loc4_40: init type = call constants.%Int(%int_32.loc4_40) [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_40.1: type = value_of_initializer %int.make_type_signed.loc4_40 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_40.2: type = converted %int.make_type_signed.loc4_40, %.loc4_40.1 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %impl.elem0.loc4_37: %.dc4 = impl_witness_access constants.%impl_witness.d9b, element0 [concrete = constants.%Convert.5bc] +// CHECK:STDOUT: %bound_method.loc4_37: = bound_method %int_2, %impl.elem0.loc4_37 [concrete = constants.%Convert.bound.324] +// CHECK:STDOUT: %int.convert_checked.loc4_37: init %i32.builtin = call %bound_method.loc4_37(%int_2) [concrete = constants.%int_2.5a1] +// CHECK:STDOUT: %.loc4_37.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_37 [concrete = constants.%int_2.5a1] +// CHECK:STDOUT: %.loc4_37.2: %i32.builtin = converted %int_2, %.loc4_37.1 [concrete = constants.%int_2.5a1] +// CHECK:STDOUT: %impl.elem0.loc4_32.1: %.7c2 = impl_witness_access constants.%impl_witness.bd0, element0 [concrete = constants.%Op.0e2] +// CHECK:STDOUT: %bound_method.loc4_32.1: = bound_method %.loc4_24.2, %impl.elem0.loc4_32.1 [concrete = constants.%Op.bound.393] +// CHECK:STDOUT: %int.sadd: init %i32.builtin = call %bound_method.loc4_32.1(%.loc4_24.2, %.loc4_37.2) [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_16.1: type = value_of_initializer %int.make_type_signed.loc4_16 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_16.2: type = converted %int.make_type_signed.loc4_16, %.loc4_16.1 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %impl.elem0.loc4_32.2: %.38f = impl_witness_access constants.%impl_witness.8f3, element0 [concrete = constants.%Convert.b32] +// CHECK:STDOUT: %bound_method.loc4_32.2: = bound_method %int.sadd, %impl.elem0.loc4_32.2 [concrete = constants.%Convert.bound.65a] +// CHECK:STDOUT: %.loc4_32.1: %i32.builtin = value_of_initializer %int.sadd [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_32.2: %i32.builtin = converted %int.sadd, %.loc4_32.1 [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %int.convert_checked.loc4_32: init Core.IntLiteral = call %bound_method.loc4_32.2(%.loc4_32.2) [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc4_32.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc4_32 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc4_32.4: Core.IntLiteral = converted %int.sadd, %.loc4_32.3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %.loc4_32.4, %i32.builtin [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var // CHECK:STDOUT: } @@ -855,51 +855,51 @@ var arr: [i32; (1 as i32) + (2 as i32)] = (3, 4, (3 as i32) + (4 as i32)); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %int_3.loc4_44: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %int_4.loc4_47: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1] -// CHECK:STDOUT: %int_3.loc4_51: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %int_32.loc4_56: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %int.make_type_signed.loc4_56: init type = call constants.%Int(%int_32.loc4_56) [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_56.1: type = value_of_initializer %int.make_type_signed.loc4_56 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_56.2: type = converted %int.make_type_signed.loc4_56, %.loc4_56.1 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %impl.elem0.loc4_53: %.dc4 = impl_witness_access constants.%impl_witness.d9b, element0 [concrete = constants.%Convert.5bc] -// CHECK:STDOUT: %bound_method.loc4_53: = bound_method %int_3.loc4_51, %impl.elem0.loc4_53 [concrete = constants.%Convert.bound.94d] -// CHECK:STDOUT: %int.convert_checked.loc4_53: init %i32.builtin = call %bound_method.loc4_53(%int_3.loc4_51) [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_53.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_53 [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_53.2: %i32.builtin = converted %int_3.loc4_51, %.loc4_53.1 [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %int_4.loc4_64: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1] -// CHECK:STDOUT: %int_32.loc4_69: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %int.make_type_signed.loc4_69: init type = call constants.%Int(%int_32.loc4_69) [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_69.1: type = value_of_initializer %int.make_type_signed.loc4_69 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_69.2: type = converted %int.make_type_signed.loc4_69, %.loc4_69.1 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %impl.elem0.loc4_66: %.dc4 = impl_witness_access constants.%impl_witness.d9b, element0 [concrete = constants.%Convert.5bc] -// CHECK:STDOUT: %bound_method.loc4_66: = bound_method %int_4.loc4_64, %impl.elem0.loc4_66 [concrete = constants.%Convert.bound.8fc] -// CHECK:STDOUT: %int.convert_checked.loc4_66: init %i32.builtin = call %bound_method.loc4_66(%int_4.loc4_64) [concrete = constants.%int_4.4f1] -// CHECK:STDOUT: %.loc4_66.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_66 [concrete = constants.%int_4.4f1] -// CHECK:STDOUT: %.loc4_66.2: %i32.builtin = converted %int_4.loc4_64, %.loc4_66.1 [concrete = constants.%int_4.4f1] -// CHECK:STDOUT: %impl.elem0.loc4_61: %.7c2 = impl_witness_access constants.%impl_witness.bd0, element0 [concrete = constants.%Op.0e2] -// CHECK:STDOUT: %bound_method.loc4_61: = bound_method %.loc4_53.2, %impl.elem0.loc4_61 [concrete = constants.%Op.bound.423] -// CHECK:STDOUT: %int.sadd: init %i32.builtin = call %bound_method.loc4_61(%.loc4_53.2, %.loc4_66.2) [concrete = constants.%int_7] -// CHECK:STDOUT: %.loc4_73.1: %tuple.type = tuple_literal (%int_3.loc4_44, %int_4.loc4_47, %int.sadd) -// CHECK:STDOUT: %impl.elem0.loc4_73.1: %.624 = impl_witness_access constants.%impl_witness.39c, element0 [concrete = constants.%Convert.cb5] -// CHECK:STDOUT: %bound_method.loc4_73.1: = bound_method %int_3.loc4_44, %impl.elem0.loc4_73.1 [concrete = constants.%Convert.bound.b6b] -// CHECK:STDOUT: %int.convert_checked.loc4_73.1: init %i32.builtin = call %bound_method.loc4_73.1(%int_3.loc4_44) [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_73.2: init %i32.builtin = converted %int_3.loc4_44, %int.convert_checked.loc4_73.1 [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %int_3.loc4_49: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %int_4.loc4_52: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1] +// CHECK:STDOUT: %int_3.loc4_56: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %int_32.loc4_61: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed.loc4_61: init type = call constants.%Int(%int_32.loc4_61) [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_61.1: type = value_of_initializer %int.make_type_signed.loc4_61 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_61.2: type = converted %int.make_type_signed.loc4_61, %.loc4_61.1 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %impl.elem0.loc4_58: %.dc4 = impl_witness_access constants.%impl_witness.d9b, element0 [concrete = constants.%Convert.5bc] +// CHECK:STDOUT: %bound_method.loc4_58: = bound_method %int_3.loc4_56, %impl.elem0.loc4_58 [concrete = constants.%Convert.bound.94d] +// CHECK:STDOUT: %int.convert_checked.loc4_58: init %i32.builtin = call %bound_method.loc4_58(%int_3.loc4_56) [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_58.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_58 [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_58.2: %i32.builtin = converted %int_3.loc4_56, %.loc4_58.1 [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %int_4.loc4_69: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1] +// CHECK:STDOUT: %int_32.loc4_74: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed.loc4_74: init type = call constants.%Int(%int_32.loc4_74) [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_74.1: type = value_of_initializer %int.make_type_signed.loc4_74 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_74.2: type = converted %int.make_type_signed.loc4_74, %.loc4_74.1 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %impl.elem0.loc4_71: %.dc4 = impl_witness_access constants.%impl_witness.d9b, element0 [concrete = constants.%Convert.5bc] +// CHECK:STDOUT: %bound_method.loc4_71: = bound_method %int_4.loc4_69, %impl.elem0.loc4_71 [concrete = constants.%Convert.bound.8fc] +// CHECK:STDOUT: %int.convert_checked.loc4_71: init %i32.builtin = call %bound_method.loc4_71(%int_4.loc4_69) [concrete = constants.%int_4.4f1] +// CHECK:STDOUT: %.loc4_71.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_71 [concrete = constants.%int_4.4f1] +// CHECK:STDOUT: %.loc4_71.2: %i32.builtin = converted %int_4.loc4_69, %.loc4_71.1 [concrete = constants.%int_4.4f1] +// CHECK:STDOUT: %impl.elem0.loc4_66: %.7c2 = impl_witness_access constants.%impl_witness.bd0, element0 [concrete = constants.%Op.0e2] +// CHECK:STDOUT: %bound_method.loc4_66: = bound_method %.loc4_58.2, %impl.elem0.loc4_66 [concrete = constants.%Op.bound.423] +// CHECK:STDOUT: %int.sadd: init %i32.builtin = call %bound_method.loc4_66(%.loc4_58.2, %.loc4_71.2) [concrete = constants.%int_7] +// CHECK:STDOUT: %.loc4_78.1: %tuple.type = tuple_literal (%int_3.loc4_49, %int_4.loc4_52, %int.sadd) +// CHECK:STDOUT: %impl.elem0.loc4_78.1: %.624 = impl_witness_access constants.%impl_witness.39c, element0 [concrete = constants.%Convert.cb5] +// CHECK:STDOUT: %bound_method.loc4_78.1: = bound_method %int_3.loc4_49, %impl.elem0.loc4_78.1 [concrete = constants.%Convert.bound.b6b] +// CHECK:STDOUT: %int.convert_checked.loc4_78.1: init %i32.builtin = call %bound_method.loc4_78.1(%int_3.loc4_49) [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_78.2: init %i32.builtin = converted %int_3.loc4_49, %int.convert_checked.loc4_78.1 [concrete = constants.%int_3.a0f] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc4_73.3: ref %i32.builtin = array_index file.%arr.var, %int_0 -// CHECK:STDOUT: %.loc4_73.4: init %i32.builtin = initialize_from %.loc4_73.2 to %.loc4_73.3 [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %impl.elem0.loc4_73.2: %.624 = impl_witness_access constants.%impl_witness.39c, element0 [concrete = constants.%Convert.cb5] -// CHECK:STDOUT: %bound_method.loc4_73.2: = bound_method %int_4.loc4_47, %impl.elem0.loc4_73.2 [concrete = constants.%Convert.bound.626] -// CHECK:STDOUT: %int.convert_checked.loc4_73.2: init %i32.builtin = call %bound_method.loc4_73.2(%int_4.loc4_47) [concrete = constants.%int_4.4f1] -// CHECK:STDOUT: %.loc4_73.5: init %i32.builtin = converted %int_4.loc4_47, %int.convert_checked.loc4_73.2 [concrete = constants.%int_4.4f1] +// CHECK:STDOUT: %.loc4_78.3: ref %i32.builtin = array_index file.%arr.var, %int_0 +// CHECK:STDOUT: %.loc4_78.4: init %i32.builtin = initialize_from %.loc4_78.2 to %.loc4_78.3 [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %impl.elem0.loc4_78.2: %.624 = impl_witness_access constants.%impl_witness.39c, element0 [concrete = constants.%Convert.cb5] +// CHECK:STDOUT: %bound_method.loc4_78.2: = bound_method %int_4.loc4_52, %impl.elem0.loc4_78.2 [concrete = constants.%Convert.bound.626] +// CHECK:STDOUT: %int.convert_checked.loc4_78.2: init %i32.builtin = call %bound_method.loc4_78.2(%int_4.loc4_52) [concrete = constants.%int_4.4f1] +// CHECK:STDOUT: %.loc4_78.5: init %i32.builtin = converted %int_4.loc4_52, %int.convert_checked.loc4_78.2 [concrete = constants.%int_4.4f1] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc4_73.6: ref %i32.builtin = array_index file.%arr.var, %int_1 -// CHECK:STDOUT: %.loc4_73.7: init %i32.builtin = initialize_from %.loc4_73.5 to %.loc4_73.6 [concrete = constants.%int_4.4f1] +// CHECK:STDOUT: %.loc4_78.6: ref %i32.builtin = array_index file.%arr.var, %int_1 +// CHECK:STDOUT: %.loc4_78.7: init %i32.builtin = initialize_from %.loc4_78.5 to %.loc4_78.6 [concrete = constants.%int_4.4f1] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc4_73.8: ref %i32.builtin = array_index file.%arr.var, %int_2 -// CHECK:STDOUT: %.loc4_73.9: init %i32.builtin = initialize_from %int.sadd to %.loc4_73.8 [concrete = constants.%int_7] -// CHECK:STDOUT: %.loc4_73.10: init %array_type = array_init (%.loc4_73.4, %.loc4_73.7, %.loc4_73.9) to file.%arr.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc4_1: init %array_type = converted %.loc4_73.1, %.loc4_73.10 [concrete = constants.%array] +// CHECK:STDOUT: %.loc4_78.8: ref %i32.builtin = array_index file.%arr.var, %int_2 +// CHECK:STDOUT: %.loc4_78.9: init %i32.builtin = initialize_from %int.sadd to %.loc4_78.8 [concrete = constants.%int_7] +// CHECK:STDOUT: %.loc4_78.10: init %array_type = array_init (%.loc4_78.4, %.loc4_78.7, %.loc4_78.9) to file.%arr.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc4_1: init %array_type = converted %.loc4_78.1, %.loc4_78.10 [concrete = constants.%array] // CHECK:STDOUT: assign file.%arr.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/builtin/no_prelude/import.carbon b/toolchain/check/testdata/function/builtin/no_prelude/import.carbon index 07e98bae44fa..d9740c3f796d 100644 --- a/toolchain/check/testdata/function/builtin/no_prelude/import.carbon +++ b/toolchain/check/testdata/function/builtin/no_prelude/import.carbon @@ -25,7 +25,7 @@ fn TestAdd(a: i32, b: i32) -> i32 = "int.sadd"; import Core library "core"; -var arr: [i32; Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))] = (Core.AsI32(1), Core.AsI32(2), Core.AsI32(3)); +var arr: array(i32, Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))) = (Core.AsI32(1), Core.AsI32(2), Core.AsI32(3)); // CHECK:STDOUT: --- core.carbon // CHECK:STDOUT: @@ -210,34 +210,34 @@ var arr: [i32; Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))] = // CHECK:STDOUT: %.loc4_1: %array_type = var_pattern %arr.patt // CHECK:STDOUT: } // CHECK:STDOUT: %arr.var: ref %array_type = var arr -// CHECK:STDOUT: %.loc4_77: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc4_82: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %Core.ref.loc4_16: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %Core.ref.loc4_21: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %AsIntLiteral.ref: %AsIntLiteral.type = name_ref AsIntLiteral, imports.%Core.AsIntLiteral [concrete = constants.%AsIntLiteral] -// CHECK:STDOUT: %Core.ref.loc4_34: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %Core.ref.loc4_39: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %TestAdd.ref: %TestAdd.type = name_ref TestAdd, imports.%Core.TestAdd [concrete = constants.%TestAdd] -// CHECK:STDOUT: %Core.ref.loc4_47: = name_ref Core, imports.%Core [concrete = imports.%Core] -// CHECK:STDOUT: %AsI32.ref.loc4_51: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] +// CHECK:STDOUT: %Core.ref.loc4_52: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %AsI32.ref.loc4_56: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int.convert_checked.loc4_59: init %i32.builtin = call %AsI32.ref.loc4_51(%int_1) [concrete = constants.%int_1.f38] -// CHECK:STDOUT: %Core.ref.loc4_62: = name_ref Core, imports.%Core [concrete = imports.%Core] -// CHECK:STDOUT: %AsI32.ref.loc4_66: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] +// CHECK:STDOUT: %int.convert_checked.loc4_64: init %i32.builtin = call %AsI32.ref.loc4_56(%int_1) [concrete = constants.%int_1.f38] +// CHECK:STDOUT: %Core.ref.loc4_67: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %AsI32.ref.loc4_71: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %int.convert_checked.loc4_74: init %i32.builtin = call %AsI32.ref.loc4_66(%int_2) [concrete = constants.%int_2.5a1] -// CHECK:STDOUT: %.loc4_59.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_59 [concrete = constants.%int_1.f38] -// CHECK:STDOUT: %.loc4_59.2: %i32.builtin = converted %int.convert_checked.loc4_59, %.loc4_59.1 [concrete = constants.%int_1.f38] -// CHECK:STDOUT: %.loc4_74.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_74 [concrete = constants.%int_2.5a1] -// CHECK:STDOUT: %.loc4_74.2: %i32.builtin = converted %int.convert_checked.loc4_74, %.loc4_74.1 [concrete = constants.%int_2.5a1] -// CHECK:STDOUT: %int.sadd: init %i32.builtin = call %TestAdd.ref(%.loc4_59.2, %.loc4_74.2) [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_75.1: %i32.builtin = value_of_initializer %int.sadd [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_75.2: %i32.builtin = converted %int.sadd, %.loc4_75.1 [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %int.convert_checked.loc4_76: init Core.IntLiteral = call %AsIntLiteral.ref(%.loc4_75.2) [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_signed [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_signed, %.loc4_11.1 [concrete = constants.%i32.builtin] -// CHECK:STDOUT: %.loc4_76.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc4_76 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc4_76.2: Core.IntLiteral = converted %int.convert_checked.loc4_76, %.loc4_76.1 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type: type = array_type %.loc4_76.2, %i32.builtin [concrete = constants.%array_type] +// CHECK:STDOUT: %int.convert_checked.loc4_79: init %i32.builtin = call %AsI32.ref.loc4_71(%int_2) [concrete = constants.%int_2.5a1] +// CHECK:STDOUT: %.loc4_64.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_64 [concrete = constants.%int_1.f38] +// CHECK:STDOUT: %.loc4_64.2: %i32.builtin = converted %int.convert_checked.loc4_64, %.loc4_64.1 [concrete = constants.%int_1.f38] +// CHECK:STDOUT: %.loc4_79.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_79 [concrete = constants.%int_2.5a1] +// CHECK:STDOUT: %.loc4_79.2: %i32.builtin = converted %int.convert_checked.loc4_79, %.loc4_79.1 [concrete = constants.%int_2.5a1] +// CHECK:STDOUT: %int.sadd: init %i32.builtin = call %TestAdd.ref(%.loc4_64.2, %.loc4_79.2) [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_80.1: %i32.builtin = value_of_initializer %int.sadd [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_80.2: %i32.builtin = converted %int.sadd, %.loc4_80.1 [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %int.convert_checked.loc4_81: init Core.IntLiteral = call %AsIntLiteral.ref(%.loc4_80.2) [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc4_16.1: type = value_of_initializer %int.make_type_signed [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_16.2: type = converted %int.make_type_signed, %.loc4_16.1 [concrete = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_81.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc4_81 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc4_81.2: Core.IntLiteral = converted %int.convert_checked.loc4_81, %.loc4_81.1 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %.loc4_81.2, %i32.builtin [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var // CHECK:STDOUT: } @@ -252,30 +252,30 @@ var arr: [i32; Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))] = // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Core.ref.loc4_82: = name_ref Core, imports.%Core [concrete = imports.%Core] -// CHECK:STDOUT: %AsI32.ref.loc4_86: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] -// CHECK:STDOUT: %int_1.loc4_93: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int.convert_checked.loc4_94: init %i32.builtin = call %AsI32.ref.loc4_86(%int_1.loc4_93) [concrete = constants.%int_1.f38] -// CHECK:STDOUT: %Core.ref.loc4_97: = name_ref Core, imports.%Core [concrete = imports.%Core] -// CHECK:STDOUT: %AsI32.ref.loc4_101: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] -// CHECK:STDOUT: %int_2.loc4_108: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %int.convert_checked.loc4_109: init %i32.builtin = call %AsI32.ref.loc4_101(%int_2.loc4_108) [concrete = constants.%int_2.5a1] -// CHECK:STDOUT: %Core.ref.loc4_112: = name_ref Core, imports.%Core [concrete = imports.%Core] -// CHECK:STDOUT: %AsI32.ref.loc4_116: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] +// CHECK:STDOUT: %Core.ref.loc4_87: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %AsI32.ref.loc4_91: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] +// CHECK:STDOUT: %int_1.loc4_98: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int.convert_checked.loc4_99: init %i32.builtin = call %AsI32.ref.loc4_91(%int_1.loc4_98) [concrete = constants.%int_1.f38] +// CHECK:STDOUT: %Core.ref.loc4_102: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %AsI32.ref.loc4_106: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] +// CHECK:STDOUT: %int_2.loc4_113: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int.convert_checked.loc4_114: init %i32.builtin = call %AsI32.ref.loc4_106(%int_2.loc4_113) [concrete = constants.%int_2.5a1] +// CHECK:STDOUT: %Core.ref.loc4_117: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %AsI32.ref.loc4_121: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %int.convert_checked.loc4_124: init %i32.builtin = call %AsI32.ref.loc4_116(%int_3) [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_125.1: %tuple.type = tuple_literal (%int.convert_checked.loc4_94, %int.convert_checked.loc4_109, %int.convert_checked.loc4_124) +// CHECK:STDOUT: %int.convert_checked.loc4_129: init %i32.builtin = call %AsI32.ref.loc4_121(%int_3) [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_130.1: %tuple.type = tuple_literal (%int.convert_checked.loc4_99, %int.convert_checked.loc4_114, %int.convert_checked.loc4_129) // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc4_125.2: ref %i32.builtin = array_index file.%arr.var, %int_0 -// CHECK:STDOUT: %.loc4_125.3: init %i32.builtin = initialize_from %int.convert_checked.loc4_94 to %.loc4_125.2 [concrete = constants.%int_1.f38] -// CHECK:STDOUT: %int_1.loc4_125: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc4_125.4: ref %i32.builtin = array_index file.%arr.var, %int_1.loc4_125 -// CHECK:STDOUT: %.loc4_125.5: init %i32.builtin = initialize_from %int.convert_checked.loc4_109 to %.loc4_125.4 [concrete = constants.%int_2.5a1] -// CHECK:STDOUT: %int_2.loc4_125: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc4_125.6: ref %i32.builtin = array_index file.%arr.var, %int_2.loc4_125 -// CHECK:STDOUT: %.loc4_125.7: init %i32.builtin = initialize_from %int.convert_checked.loc4_124 to %.loc4_125.6 [concrete = constants.%int_3.a0f] -// CHECK:STDOUT: %.loc4_125.8: init %array_type = array_init (%.loc4_125.3, %.loc4_125.5, %.loc4_125.7) to file.%arr.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc4_1: init %array_type = converted %.loc4_125.1, %.loc4_125.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc4_130.2: ref %i32.builtin = array_index file.%arr.var, %int_0 +// CHECK:STDOUT: %.loc4_130.3: init %i32.builtin = initialize_from %int.convert_checked.loc4_99 to %.loc4_130.2 [concrete = constants.%int_1.f38] +// CHECK:STDOUT: %int_1.loc4_130: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc4_130.4: ref %i32.builtin = array_index file.%arr.var, %int_1.loc4_130 +// CHECK:STDOUT: %.loc4_130.5: init %i32.builtin = initialize_from %int.convert_checked.loc4_114 to %.loc4_130.4 [concrete = constants.%int_2.5a1] +// CHECK:STDOUT: %int_2.loc4_130: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc4_130.6: ref %i32.builtin = array_index file.%arr.var, %int_2.loc4_130 +// CHECK:STDOUT: %.loc4_130.7: init %i32.builtin = initialize_from %int.convert_checked.loc4_129 to %.loc4_130.6 [concrete = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_130.8: init %array_type = array_init (%.loc4_130.3, %.loc4_130.5, %.loc4_130.7) to file.%arr.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc4_1: init %array_type = converted %.loc4_130.1, %.loc4_130.8 [concrete = constants.%array] // CHECK:STDOUT: assign file.%arr.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/declaration/fail_param_in_type.carbon b/toolchain/check/testdata/function/declaration/fail_param_in_type.carbon index 7d160ebe42ed..9e27d38b916a 100644 --- a/toolchain/check/testdata/function/declaration/fail_param_in_type.carbon +++ b/toolchain/check/testdata/function/declaration/fail_param_in_type.carbon @@ -8,11 +8,11 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_param_in_type.carbon -// CHECK:STDERR: fail_param_in_type.carbon:[[@LINE+4]]:23: error: array bound is not a constant [InvalidArrayExpr] -// CHECK:STDERR: fn F(n: i32, a: [i32; n]*); -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_param_in_type.carbon:[[@LINE+4]]:28: error: array bound is not a constant [InvalidArrayExpr] +// CHECK:STDERR: fn F(n: i32, a: array(i32, n)*); +// CHECK:STDERR: ^ // CHECK:STDERR: -fn F(n: i32, a: [i32; n]*); +fn F(n: i32, a: array(i32, n)*); // CHECK:STDOUT: --- fail_param_in_type.carbon // CHECK:STDOUT: @@ -50,9 +50,9 @@ fn F(n: i32, a: [i32; n]*); // CHECK:STDOUT: } // CHECK:STDOUT: %n: %i32 = bind_name n, %n.param // CHECK:STDOUT: %a.param: = value_param runtime_param1 -// CHECK:STDOUT: %.loc15_25: type = splice_block %ptr [concrete = ] { -// CHECK:STDOUT: %int_32.loc15_18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc15_18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %.loc15_30: type = splice_block %ptr [concrete = ] { +// CHECK:STDOUT: %int_32.loc15_23: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_23: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n // CHECK:STDOUT: %ptr: type = ptr_type [concrete = ] // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/generic/param_in_type.carbon b/toolchain/check/testdata/function/generic/param_in_type.carbon index e93dbd3d8405..8900f918571d 100644 --- a/toolchain/check/testdata/function/generic/param_in_type.carbon +++ b/toolchain/check/testdata/function/generic/param_in_type.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/param_in_type.carbon -fn F(N:! i32, a: [i32; N]*); +fn F(N:! i32, a: array(i32, N)*); // CHECK:STDOUT: --- param_in_type.carbon // CHECK:STDOUT: @@ -51,8 +51,8 @@ fn F(N:! i32, a: [i32; N]*); // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %N.patt.loc11_6.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc11_6.2 (constants.%N.patt.8e2)] // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc11_6.1, runtime_param [symbolic = %N.patt.loc11_6.2 (constants.%N.patt.8e2)] -// CHECK:STDOUT: %a.patt: @F.%ptr.loc11_26.2 (%ptr) = binding_pattern a -// CHECK:STDOUT: %a.param_patt: @F.%ptr.loc11_26.2 (%ptr) = value_param_pattern %a.patt, runtime_param0 +// CHECK:STDOUT: %a.patt: @F.%ptr.loc11_31.2 (%ptr) = binding_pattern a +// CHECK:STDOUT: %a.param_patt: @F.%ptr.loc11_31.2 (%ptr) = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param // CHECK:STDOUT: %.loc11_10: type = splice_block %i32.loc11_10 [concrete = constants.%i32] { @@ -60,21 +60,21 @@ fn F(N:! i32, a: [i32; N]*); // CHECK:STDOUT: %i32.loc11_10: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc11_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc11_6.2 (constants.%N.51e)] -// CHECK:STDOUT: %a.param: @F.%ptr.loc11_26.2 (%ptr) = value_param runtime_param0 -// CHECK:STDOUT: %.loc11_26: type = splice_block %ptr.loc11_26.1 [symbolic = %ptr.loc11_26.2 (constants.%ptr)] { -// CHECK:STDOUT: %int_32.loc11_19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc11_19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %a.param: @F.%ptr.loc11_31.2 (%ptr) = value_param runtime_param0 +// CHECK:STDOUT: %.loc11_31: type = splice_block %ptr.loc11_31.1 [symbolic = %ptr.loc11_31.2 (constants.%ptr)] { +// CHECK:STDOUT: %int_32.loc11_24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_24: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc11_6.1 [symbolic = %N.loc11_6.2 (constants.%N.51e)] // CHECK:STDOUT: %impl.elem0: %.10e = impl_witness_access constants.%impl_witness.023, element0 [concrete = constants.%Convert.960] // CHECK:STDOUT: %bound_method: = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound)] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked.loc11_24.1: init Core.IntLiteral = call %specific_fn(%N.ref) [symbolic = %int.convert_checked.loc11_24.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc11_24.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc11_24.1 [symbolic = %int.convert_checked.loc11_24.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %.loc11_24.2: Core.IntLiteral = converted %N.ref, %.loc11_24.1 [symbolic = %int.convert_checked.loc11_24.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc11_25.1: type = array_type %.loc11_24.2, %i32 [symbolic = %array_type.loc11_25.2 (constants.%array_type)] -// CHECK:STDOUT: %ptr.loc11_26.1: type = ptr_type %array_type [symbolic = %ptr.loc11_26.2 (constants.%ptr)] +// CHECK:STDOUT: %int.convert_checked.loc11_29.1: init Core.IntLiteral = call %specific_fn(%N.ref) [symbolic = %int.convert_checked.loc11_29.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc11_29.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc11_29.1 [symbolic = %int.convert_checked.loc11_29.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc11_29.2: Core.IntLiteral = converted %N.ref, %.loc11_29.1 [symbolic = %int.convert_checked.loc11_29.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc11_30.1: type = array_type %.loc11_29.2, %i32 [symbolic = %array_type.loc11_30.2 (constants.%array_type)] +// CHECK:STDOUT: %ptr.loc11_31.1: type = ptr_type %array_type [symbolic = %ptr.loc11_31.2 (constants.%ptr)] // CHECK:STDOUT: } -// CHECK:STDOUT: %a: @F.%ptr.loc11_26.2 (%ptr) = bind_name a, %a.param +// CHECK:STDOUT: %a: @F.%ptr.loc11_31.2 (%ptr) = bind_name a, %a.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -83,11 +83,11 @@ fn F(N:! i32, a: [i32; N]*); // CHECK:STDOUT: %N.patt.loc11_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc11_6.2 (constants.%N.patt.8e2)] // CHECK:STDOUT: %Convert.bound: = bound_method %N.loc11_6.2, constants.%Convert.960 [symbolic = %Convert.bound (constants.%Convert.bound)] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked.loc11_24.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc11_6.2) [symbolic = %int.convert_checked.loc11_24.2 (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type.loc11_25.2: type = array_type %int.convert_checked.loc11_24.2, %i32 [symbolic = %array_type.loc11_25.2 (constants.%array_type)] -// CHECK:STDOUT: %ptr.loc11_26.2: type = ptr_type @F.%array_type.loc11_25.2 (%array_type) [symbolic = %ptr.loc11_26.2 (constants.%ptr)] +// CHECK:STDOUT: %int.convert_checked.loc11_29.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc11_6.2) [symbolic = %int.convert_checked.loc11_29.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc11_30.2: type = array_type %int.convert_checked.loc11_29.2, %i32 [symbolic = %array_type.loc11_30.2 (constants.%array_type)] +// CHECK:STDOUT: %ptr.loc11_31.2: type = ptr_type @F.%array_type.loc11_30.2 (%array_type) [symbolic = %ptr.loc11_31.2 (constants.%ptr)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%N.param_patt: %i32, %a.param_patt: @F.%ptr.loc11_26.2 (%ptr)); +// CHECK:STDOUT: fn(%N.param_patt: %i32, %a.param_patt: @F.%ptr.loc11_31.2 (%ptr)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F(constants.%N.51e) { @@ -95,8 +95,8 @@ fn F(N:! i32, a: [i32; N]*); // CHECK:STDOUT: %N.patt.loc11_6.2 => constants.%N.51e // CHECK:STDOUT: %Convert.bound => constants.%Convert.bound // CHECK:STDOUT: %Convert.specific_fn => constants.%Convert.specific_fn -// CHECK:STDOUT: %int.convert_checked.loc11_24.2 => constants.%int.convert_checked -// CHECK:STDOUT: %array_type.loc11_25.2 => constants.%array_type -// CHECK:STDOUT: %ptr.loc11_26.2 => constants.%ptr +// CHECK:STDOUT: %int.convert_checked.loc11_29.2 => constants.%int.convert_checked +// CHECK:STDOUT: %array_type.loc11_30.2 => constants.%array_type +// CHECK:STDOUT: %ptr.loc11_31.2 => constants.%ptr // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/return_slot.carbon b/toolchain/check/testdata/function/generic/return_slot.carbon index 9059b60b0d1e..de413df13350 100644 --- a/toolchain/check/testdata/function/generic/return_slot.carbon +++ b/toolchain/check/testdata/function/generic/return_slot.carbon @@ -12,7 +12,7 @@ class Wrap(T:! type) { fn Make() -> T { return Make(); } } -class C { var arr: [i32; 100]; } +class C { var arr: array(i32, 100); } fn G() { var a: i32 = Wrap(i32).Make(); diff --git a/toolchain/check/testdata/if_expr/basic.carbon b/toolchain/check/testdata/if_expr/basic.carbon index f3b14049e26e..734a1e68ac92 100644 --- a/toolchain/check/testdata/if_expr/basic.carbon +++ b/toolchain/check/testdata/if_expr/basic.carbon @@ -9,7 +9,7 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/if_expr/basic.carbon fn F(b: bool, n: i32, m: i32) -> i32 { - var x: [i32; 1] = (0,); + var x: array(i32, 1) = (0,); return if b then x[m] else x[n]; } @@ -98,20 +98,20 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: %.loc12_3.1: %array_type = var_pattern %x.patt // CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %array_type = var x -// CHECK:STDOUT: %int_0.loc12_22: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc12_24.1: %tuple.type = tuple_literal (%int_0.loc12_22) +// CHECK:STDOUT: %int_0.loc12_27: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc12_29.1: %tuple.type = tuple_literal (%int_0.loc12_27) // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method: = bound_method %int_0.loc12_22, %impl.elem0 [concrete = constants.%Convert.bound] +// CHECK:STDOUT: %bound_method: = bound_method %int_0.loc12_27, %impl.elem0 [concrete = constants.%Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0.loc12_22) [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc12_24.2: init %i32 = converted %int_0.loc12_22, %int.convert_checked [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %int_0.loc12_24: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc12_24.3: ref %i32 = array_index %x.var, %int_0.loc12_24 -// CHECK:STDOUT: %.loc12_24.4: init %i32 = initialize_from %.loc12_24.2 to %.loc12_24.3 [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc12_24.5: init %array_type = array_init (%.loc12_24.4) to %x.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc12_3.2: init %array_type = converted %.loc12_24.1, %.loc12_24.5 [concrete = constants.%array] +// CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0.loc12_27) [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc12_29.2: init %i32 = converted %int_0.loc12_27, %int.convert_checked [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %int_0.loc12_29: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc12_29.3: ref %i32 = array_index %x.var, %int_0.loc12_29 +// CHECK:STDOUT: %.loc12_29.4: init %i32 = initialize_from %.loc12_29.2 to %.loc12_29.3 [concrete = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc12_29.5: init %array_type = array_init (%.loc12_29.4) to %x.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc12_3.2: init %array_type = converted %.loc12_29.1, %.loc12_29.5 [concrete = constants.%array] // CHECK:STDOUT: assign %x.var, %.loc12_3.2 -// CHECK:STDOUT: %.loc12_17: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc12_22: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] diff --git a/toolchain/check/testdata/impl/assoc_const_self.carbon b/toolchain/check/testdata/impl/assoc_const_self.carbon index 37f4cf449bfb..ed69f1d5d6e7 100644 --- a/toolchain/check/testdata/impl/assoc_const_self.carbon +++ b/toolchain/check/testdata/impl/assoc_const_self.carbon @@ -62,10 +62,10 @@ impl C as I where .V = () {} library "[[@TEST_NAME]]"; interface I(N:! Core.IntLiteral()) { - // CHECK:STDERR: fail_monomorphization_failure.carbon:[[@LINE+3]]:12: error: array bound of -1 is negative [ArrayBoundNegative] - // CHECK:STDERR: let V:! [Self; N]; - // CHECK:STDERR: ^~~~ - let V:! [Self; N]; + // CHECK:STDERR: fail_monomorphization_failure.carbon:[[@LINE+3]]:17: error: array bound of -1 is negative [ArrayBoundNegative] + // CHECK:STDERR: let V:! array(Self, N); + // CHECK:STDERR: ^~~~ + let V:! array(Self, N); } // CHECK:STDERR: fail_monomorphization_failure.carbon:[[@LINE+4]]:24: note: in `V` used here [ResolvingSpecificHere] diff --git a/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon b/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon index d2141c819e10..4f7df849a764 100644 --- a/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon +++ b/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon @@ -185,32 +185,32 @@ class FDifferentParamName { } interface SelfNested { - fn F(x: (Self*, {.x: Self, .y: i32})) -> [Self; 4]; + fn F(x: (Self*, {.x: Self, .y: i32})) -> array(Self, 4); } class SelfNestedBadParam { impl as SelfNested { // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE+7]]:10: error: type `(SelfNestedBadParam*, {.x: i32, .y: i32})` of parameter 1 in redeclaration differs from previous parameter type `(SelfNestedBadParam*, {.x: SelfNestedBadParam, .y: i32})` [RedeclParamDiffersType] - // CHECK:STDERR: fn F(x: (SelfNestedBadParam*, {.x: i32, .y: i32})) -> [SelfNestedBadParam; 4]; + // CHECK:STDERR: fn F(x: (SelfNestedBadParam*, {.x: i32, .y: i32})) -> array(SelfNestedBadParam, 4); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE-8]]:8: note: previous declaration's corresponding parameter here [RedeclParamPrevious] - // CHECK:STDERR: fn F(x: (Self*, {.x: Self, .y: i32})) -> [Self; 4]; + // CHECK:STDERR: fn F(x: (Self*, {.x: Self, .y: i32})) -> array(Self, 4); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: - fn F(x: (SelfNestedBadParam*, {.x: i32, .y: i32})) -> [SelfNestedBadParam; 4]; + fn F(x: (SelfNestedBadParam*, {.x: i32, .y: i32})) -> array(SelfNestedBadParam, 4); } } class SelfNestedBadReturnType { impl as SelfNested { // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE+7]]:5: error: function redeclaration differs because return type is `[SelfNestedBadParam; 4]` [FunctionRedeclReturnTypeDiffers] - // CHECK:STDERR: fn F(x: (SelfNestedBadReturnType*, {.x: SelfNestedBadReturnType, .y: i32})) -> [SelfNestedBadParam; 4]; - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fn F(x: (SelfNestedBadReturnType*, {.x: SelfNestedBadReturnType, .y: i32})) -> array(SelfNestedBadParam, 4); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE-21]]:3: note: previously declared with return type `[SelfNestedBadReturnType; 4]` [FunctionRedeclReturnTypePrevious] - // CHECK:STDERR: fn F(x: (Self*, {.x: Self, .y: i32})) -> [Self; 4]; - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fn F(x: (Self*, {.x: Self, .y: i32})) -> array(Self, 4); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: - fn F(x: (SelfNestedBadReturnType*, {.x: SelfNestedBadReturnType, .y: i32})) -> [SelfNestedBadParam; 4]; + fn F(x: (SelfNestedBadReturnType*, {.x: SelfNestedBadReturnType, .y: i32})) -> array(SelfNestedBadParam, 4); } } @@ -437,14 +437,14 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: %F.decl: %F.type.6ed = fn_decl @F.13 [concrete = constants.%F.998] { // CHECK:STDOUT: %x.patt: @F.13.%tuple.type (%tuple.type.229) = binding_pattern x // CHECK:STDOUT: %x.param_patt: @F.13.%tuple.type (%tuple.type.229) = value_param_pattern %x.patt, runtime_param0 -// CHECK:STDOUT: %return.patt: @F.13.%array_type.loc188_52.1 (%array_type.873) = return_slot_pattern -// CHECK:STDOUT: %return.param_patt: @F.13.%array_type.loc188_52.1 (%array_type.873) = out_param_pattern %return.patt, runtime_param1 +// CHECK:STDOUT: %return.patt: @F.13.%array_type.loc188_57.1 (%array_type.873) = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: @F.13.%array_type.loc188_57.1 (%array_type.873) = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { -// CHECK:STDOUT: %Self.ref.loc188_45: %SelfNested.type = name_ref Self, @SelfNested.%Self [symbolic = %Self (constants.%Self.2ff)] +// CHECK:STDOUT: %Self.ref.loc188_50: %SelfNested.type = name_ref Self, @SelfNested.%Self [symbolic = %Self (constants.%Self.2ff)] // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4] -// CHECK:STDOUT: %Self.as_type.loc188_45: type = facet_access_type %Self.ref.loc188_45 [symbolic = %Self.as_type.loc188_16.1 (constants.%Self.as_type)] -// CHECK:STDOUT: %.loc188_45: type = converted %Self.ref.loc188_45, %Self.as_type.loc188_45 [symbolic = %Self.as_type.loc188_16.1 (constants.%Self.as_type)] -// CHECK:STDOUT: %array_type.loc188_52.2: type = array_type %int_4, %Self.as_type [symbolic = %array_type.loc188_52.1 (constants.%array_type.873)] +// CHECK:STDOUT: %Self.as_type.loc188_50: type = facet_access_type %Self.ref.loc188_50 [symbolic = %Self.as_type.loc188_16.1 (constants.%Self.as_type)] +// CHECK:STDOUT: %.loc188_50: type = converted %Self.ref.loc188_50, %Self.as_type.loc188_50 [symbolic = %Self.as_type.loc188_16.1 (constants.%Self.as_type)] +// CHECK:STDOUT: %array_type.loc188_57.2: type = array_type %int_4, %Self.as_type [symbolic = %array_type.loc188_57.1 (constants.%array_type.873)] // CHECK:STDOUT: %x.param: @F.13.%tuple.type (%tuple.type.229) = value_param runtime_param0 // CHECK:STDOUT: %.loc188_38.1: type = splice_block %.loc188_38.3 [symbolic = %tuple.type (constants.%tuple.type.229)] { // CHECK:STDOUT: %Self.ref.loc188_12: %SelfNested.type = name_ref Self, @SelfNested.%Self [symbolic = %Self (constants.%Self.2ff)] @@ -461,8 +461,8 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: %.loc188_38.3: type = converted %.loc188_38.2, constants.%tuple.type.229 [symbolic = %tuple.type (constants.%tuple.type.229)] // CHECK:STDOUT: } // CHECK:STDOUT: %x: @F.13.%tuple.type (%tuple.type.229) = bind_name x, %x.param -// CHECK:STDOUT: %return.param: ref @F.13.%array_type.loc188_52.1 (%array_type.873) = out_param runtime_param1 -// CHECK:STDOUT: %return: ref @F.13.%array_type.loc188_52.1 (%array_type.873) = return_slot %return.param +// CHECK:STDOUT: %return.param: ref @F.13.%array_type.loc188_57.1 (%array_type.873) = out_param runtime_param1 +// CHECK:STDOUT: %return: ref @F.13.%array_type.loc188_57.1 (%array_type.873) = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %assoc0: %SelfNested.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0.a58] // CHECK:STDOUT: @@ -764,7 +764,7 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: %return.patt: %array_type.a41 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %array_type.a41 = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { -// CHECK:STDOUT: %SelfNestedBadParam.ref.loc200_60: type = name_ref SelfNestedBadParam, file.%SelfNestedBadParam.decl [concrete = constants.%SelfNestedBadParam] +// CHECK:STDOUT: %SelfNestedBadParam.ref.loc200_65: type = name_ref SelfNestedBadParam, file.%SelfNestedBadParam.decl [concrete = constants.%SelfNestedBadParam] // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4] // CHECK:STDOUT: %array_type: type = array_type %int_4, %SelfNestedBadParam [concrete = constants.%array_type.a41] // CHECK:STDOUT: %x.param: %tuple.type.a7d = value_param runtime_param0 @@ -1075,9 +1075,9 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: %ptr.loc188_16.1: type = ptr_type @F.13.%Self.as_type.loc188_16.1 (%Self.as_type) [symbolic = %ptr.loc188_16.1 (constants.%ptr.e87)] // CHECK:STDOUT: %struct_type.x.y.loc188_37.1: type = struct_type {.x: @F.13.%Self.as_type.loc188_16.1 (%Self.as_type), .y: %i32} [symbolic = %struct_type.x.y.loc188_37.1 (constants.%struct_type.x.y.81e)] // CHECK:STDOUT: %tuple.type: type = tuple_type (@F.13.%ptr.loc188_16.1 (%ptr.e87), @F.13.%struct_type.x.y.loc188_37.1 (%struct_type.x.y.81e)) [symbolic = %tuple.type (constants.%tuple.type.229)] -// CHECK:STDOUT: %array_type.loc188_52.1: type = array_type constants.%int_4, @F.13.%Self.as_type.loc188_16.1 (%Self.as_type) [symbolic = %array_type.loc188_52.1 (constants.%array_type.873)] +// CHECK:STDOUT: %array_type.loc188_57.1: type = array_type constants.%int_4, @F.13.%Self.as_type.loc188_16.1 (%Self.as_type) [symbolic = %array_type.loc188_57.1 (constants.%array_type.873)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%x.param_patt: @F.13.%tuple.type (%tuple.type.229)) -> @F.13.%array_type.loc188_52.1 (%array_type.873); +// CHECK:STDOUT: fn(%x.param_patt: @F.13.%tuple.type (%tuple.type.229)) -> @F.13.%array_type.loc188_57.1 (%array_type.873); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.14(%x.param_patt: %tuple.type.a7d) -> %array_type.a41; @@ -1114,7 +1114,7 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: %ptr.loc188_16.1 => constants.%ptr.e87 // CHECK:STDOUT: %struct_type.x.y.loc188_37.1 => constants.%struct_type.x.y.81e // CHECK:STDOUT: %tuple.type => constants.%tuple.type.229 -// CHECK:STDOUT: %array_type.loc188_52.1 => constants.%array_type.873 +// CHECK:STDOUT: %array_type.loc188_57.1 => constants.%array_type.873 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F.13(constants.%SelfNested.facet.61c) { @@ -1123,7 +1123,7 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: %ptr.loc188_16.1 => constants.%ptr.4cd // CHECK:STDOUT: %struct_type.x.y.loc188_37.1 => constants.%struct_type.x.y.a89 // CHECK:STDOUT: %tuple.type => constants.%tuple.type.9c9 -// CHECK:STDOUT: %array_type.loc188_52.1 => constants.%array_type.a41 +// CHECK:STDOUT: %array_type.loc188_57.1 => constants.%array_type.a41 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F.13(constants.%SelfNested.facet.01f) { @@ -1132,6 +1132,6 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: %ptr.loc188_16.1 => constants.%ptr.612 // CHECK:STDOUT: %struct_type.x.y.loc188_37.1 => constants.%struct_type.x.y.ac5 // CHECK:STDOUT: %tuple.type => constants.%tuple.type.eb9 -// CHECK:STDOUT: %array_type.loc188_52.1 => constants.%array_type.126 +// CHECK:STDOUT: %array_type.loc188_57.1 => constants.%array_type.126 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon b/toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon index 48d71a52426d..1e63545e1f43 100644 --- a/toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon +++ b/toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon @@ -69,18 +69,18 @@ library "[[@TEST_NAME]]"; interface I { let N:! i32; - // CHECK:STDERR: fail_todo_associated_int_in_array.carbon:[[@LINE+7]]:32: error: cannot implicitly convert from `` to `Core.IntLiteral` [ImplicitAsConversionFailure] - // CHECK:STDERR: fn F[self: Self]() -> [bool; N]; - // CHECK:STDERR: ^ - // CHECK:STDERR: fail_todo_associated_int_in_array.carbon:[[@LINE+4]]:32: note: type `` does not implement interface `Core.ImplicitAs(Core.IntLiteral)` [MissingImplInMemberAccessNote] - // CHECK:STDERR: fn F[self: Self]() -> [bool; N]; - // CHECK:STDERR: ^ + // CHECK:STDERR: fail_todo_associated_int_in_array.carbon:[[@LINE+7]]:37: error: cannot implicitly convert from `` to `Core.IntLiteral` [ImplicitAsConversionFailure] + // CHECK:STDERR: fn F[self: Self]() -> array(bool, N); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_todo_associated_int_in_array.carbon:[[@LINE+4]]:37: note: type `` does not implement interface `Core.ImplicitAs(Core.IntLiteral)` [MissingImplInMemberAccessNote] + // CHECK:STDERR: fn F[self: Self]() -> array(bool, N); + // CHECK:STDERR: ^ // CHECK:STDERR: - fn F[self: Self]() -> [bool; N]; + fn F[self: Self]() -> array(bool, N); } impl () as I where .N = 2 { - fn F[self: Self]() -> [bool; 2] { return (true, false); } + fn F[self: Self]() -> array(bool, 2) { return (true, false); } } // CHECK:STDOUT: --- fail_todo_associated_type_in_signature.carbon @@ -549,9 +549,9 @@ impl () as I where .N = 2 { // CHECK:STDOUT: } { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [concrete = bool] // CHECK:STDOUT: %N.ref: %I.assoc_type = name_ref N, @N.%assoc0 [concrete = constants.%assoc0.73c] -// CHECK:STDOUT: %.loc12_26.1: type = value_of_initializer %bool.make_type [concrete = bool] -// CHECK:STDOUT: %.loc12_26.2: type = converted %bool.make_type, %.loc12_26.1 [concrete = bool] -// CHECK:STDOUT: %.loc12_32: Core.IntLiteral = converted %N.ref, [concrete = ] +// CHECK:STDOUT: %.loc12_31.1: type = value_of_initializer %bool.make_type [concrete = bool] +// CHECK:STDOUT: %.loc12_31.2: type = converted %bool.make_type, %.loc12_31.1 [concrete = bool] +// CHECK:STDOUT: %.loc12_37: Core.IntLiteral = converted %N.ref, [concrete = ] // CHECK:STDOUT: %array_type: type = array_type , bool [concrete = ] // CHECK:STDOUT: %self.param: @F.1.%Self.as_type.loc12_14.1 (%Self.as_type.b70) = value_param runtime_param0 // CHECK:STDOUT: %.loc12_14.1: type = splice_block %.loc12_14.2 [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type.b70)] { @@ -585,8 +585,8 @@ impl () as I where .N = 2 { // CHECK:STDOUT: } { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [concrete = bool] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc16_26.1: type = value_of_initializer %bool.make_type [concrete = bool] -// CHECK:STDOUT: %.loc16_26.2: type = converted %bool.make_type, %.loc16_26.1 [concrete = bool] +// CHECK:STDOUT: %.loc16_31.1: type = value_of_initializer %bool.make_type [concrete = bool] +// CHECK:STDOUT: %.loc16_31.2: type = converted %bool.make_type, %.loc16_31.1 [concrete = bool] // CHECK:STDOUT: %array_type: type = array_type %int_2, bool [concrete = constants.%array_type] // CHECK:STDOUT: %self.param: %empty_tuple.type = value_param runtime_param0 // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.44.%.loc15_7.2 [concrete = constants.%empty_tuple.type] @@ -611,16 +611,16 @@ impl () as I where .N = 2 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true] // CHECK:STDOUT: %false: bool = bool_literal false [concrete = constants.%false] -// CHECK:STDOUT: %.loc16_56.1: %tuple.type = tuple_literal (%true, %false) +// CHECK:STDOUT: %.loc16_61.1: %tuple.type = tuple_literal (%true, %false) // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc16_56.2: ref bool = array_index %return, %int_0 -// CHECK:STDOUT: %.loc16_56.3: init bool = initialize_from %true to %.loc16_56.2 [concrete = constants.%true] +// CHECK:STDOUT: %.loc16_61.2: ref bool = array_index %return, %int_0 +// CHECK:STDOUT: %.loc16_61.3: init bool = initialize_from %true to %.loc16_61.2 [concrete = constants.%true] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc16_56.4: ref bool = array_index %return, %int_1 -// CHECK:STDOUT: %.loc16_56.5: init bool = initialize_from %false to %.loc16_56.4 [concrete = constants.%false] -// CHECK:STDOUT: %.loc16_56.6: init %array_type = array_init (%.loc16_56.3, %.loc16_56.5) to %return [concrete = constants.%array] -// CHECK:STDOUT: %.loc16_57: init %array_type = converted %.loc16_56.1, %.loc16_56.6 [concrete = constants.%array] -// CHECK:STDOUT: return %.loc16_57 to %return +// CHECK:STDOUT: %.loc16_61.4: ref bool = array_index %return, %int_1 +// CHECK:STDOUT: %.loc16_61.5: init bool = initialize_from %false to %.loc16_61.4 [concrete = constants.%false] +// CHECK:STDOUT: %.loc16_61.6: init %array_type = array_init (%.loc16_61.3, %.loc16_61.5) to %return [concrete = constants.%array] +// CHECK:STDOUT: %.loc16_62: init %array_type = converted %.loc16_61.1, %.loc16_61.6 [concrete = constants.%array] +// CHECK:STDOUT: return %.loc16_62 to %return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @N(constants.%Self.826) {} diff --git a/toolchain/check/testdata/index/array_element_access.carbon b/toolchain/check/testdata/index/array_element_access.carbon index ada810ece576..f2c8a2d1c026 100644 --- a/toolchain/check/testdata/index/array_element_access.carbon +++ b/toolchain/check/testdata/index/array_element_access.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/array_element_access.carbon -var a: [i32; 2] = (12, 24); +var a: array(i32, 2) = (12, 24); var b: i32 = 1; var c: i32 = a[0]; var d: i32 = a[b]; @@ -70,7 +70,7 @@ var d: i32 = a[b]; // CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] @@ -113,25 +113,25 @@ var d: i32 = a[b]; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [concrete = constants.%int_12.6a3] // CHECK:STDOUT: %int_24: Core.IntLiteral = int_value 24 [concrete = constants.%int_24.e3c] -// CHECK:STDOUT: %.loc11_26.1: %tuple.type = tuple_literal (%int_12, %int_24) -// CHECK:STDOUT: %impl.elem0.loc11_26.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_26.1: = bound_method %int_12, %impl.elem0.loc11_26.1 [concrete = constants.%Convert.bound.221] -// CHECK:STDOUT: %specific_fn.loc11_26.1: = specific_function %bound_method.loc11_26.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.9a9] -// CHECK:STDOUT: %int.convert_checked.loc11_26.1: init %i32 = call %specific_fn.loc11_26.1(%int_12) [concrete = constants.%int_12.1e1] -// CHECK:STDOUT: %.loc11_26.2: init %i32 = converted %int_12, %int.convert_checked.loc11_26.1 [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %.loc11_31.1: %tuple.type = tuple_literal (%int_12, %int_24) +// CHECK:STDOUT: %impl.elem0.loc11_31.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_31.1: = bound_method %int_12, %impl.elem0.loc11_31.1 [concrete = constants.%Convert.bound.221] +// CHECK:STDOUT: %specific_fn.loc11_31.1: = specific_function %bound_method.loc11_31.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.9a9] +// CHECK:STDOUT: %int.convert_checked.loc11_31.1: init %i32 = call %specific_fn.loc11_31.1(%int_12) [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %.loc11_31.2: init %i32 = converted %int_12, %int.convert_checked.loc11_31.1 [concrete = constants.%int_12.1e1] // CHECK:STDOUT: %int_0.loc11: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc11_26.3: ref %i32 = array_index file.%a.var, %int_0.loc11 -// CHECK:STDOUT: %.loc11_26.4: init %i32 = initialize_from %.loc11_26.2 to %.loc11_26.3 [concrete = constants.%int_12.1e1] -// CHECK:STDOUT: %impl.elem0.loc11_26.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_26.2: = bound_method %int_24, %impl.elem0.loc11_26.2 [concrete = constants.%Convert.bound.ef4] -// CHECK:STDOUT: %specific_fn.loc11_26.2: = specific_function %bound_method.loc11_26.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.c4e] -// CHECK:STDOUT: %int.convert_checked.loc11_26.2: init %i32 = call %specific_fn.loc11_26.2(%int_24) [concrete = constants.%int_24.365] -// CHECK:STDOUT: %.loc11_26.5: init %i32 = converted %int_24, %int.convert_checked.loc11_26.2 [concrete = constants.%int_24.365] +// CHECK:STDOUT: %.loc11_31.3: ref %i32 = array_index file.%a.var, %int_0.loc11 +// CHECK:STDOUT: %.loc11_31.4: init %i32 = initialize_from %.loc11_31.2 to %.loc11_31.3 [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %impl.elem0.loc11_31.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_31.2: = bound_method %int_24, %impl.elem0.loc11_31.2 [concrete = constants.%Convert.bound.ef4] +// CHECK:STDOUT: %specific_fn.loc11_31.2: = specific_function %bound_method.loc11_31.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.c4e] +// CHECK:STDOUT: %int.convert_checked.loc11_31.2: init %i32 = call %specific_fn.loc11_31.2(%int_24) [concrete = constants.%int_24.365] +// CHECK:STDOUT: %.loc11_31.5: init %i32 = converted %int_24, %int.convert_checked.loc11_31.2 [concrete = constants.%int_24.365] // CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc11_26.6: ref %i32 = array_index file.%a.var, %int_1.loc11 -// CHECK:STDOUT: %.loc11_26.7: init %i32 = initialize_from %.loc11_26.5 to %.loc11_26.6 [concrete = constants.%int_24.365] -// CHECK:STDOUT: %.loc11_26.8: init %array_type = array_init (%.loc11_26.4, %.loc11_26.7) to file.%a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_26.1, %.loc11_26.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_31.6: ref %i32 = array_index file.%a.var, %int_1.loc11 +// CHECK:STDOUT: %.loc11_31.7: init %i32 = initialize_from %.loc11_31.5 to %.loc11_31.6 [concrete = constants.%int_24.365] +// CHECK:STDOUT: %.loc11_31.8: init %array_type = array_init (%.loc11_31.4, %.loc11_31.7) to file.%a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_31.1, %.loc11_31.8 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc12: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] diff --git a/toolchain/check/testdata/index/expr_category.carbon b/toolchain/check/testdata/index/expr_category.carbon index 72196929e970..a9067947c07f 100644 --- a/toolchain/check/testdata/index/expr_category.carbon +++ b/toolchain/check/testdata/index/expr_category.carbon @@ -8,18 +8,18 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/expr_category.carbon -fn F() -> [i32; 3]; +fn F() -> array(i32, 3); -fn G(b: [i32; 3]) { - var a: [i32; 3] = (1, 2, 3); +fn G(b: array(i32, 3)) { + var a: array(i32, 3) = (1, 2, 3); // Indexing a durable array reference gives a durable reference. var pa: i32* = &a[0]; a[0] = 4; } -fn ValueBinding(b: [i32; 3]) { - var a: [i32; 3] = (1, 2, 3); +fn ValueBinding(b: array(i32, 3)) { + var a: array(i32, 3) = (1, 2, 3); // Index but don't do anything else so we can check that a value binding is // produced when appropriate. @@ -137,42 +137,42 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %.loc14_3.1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %int_1.loc14_22: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_2.loc14_25: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %int_3.loc14_28: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc14_29.1: %tuple.type = tuple_literal (%int_1.loc14_22, %int_2.loc14_25, %int_3.loc14_28) -// CHECK:STDOUT: %impl.elem0.loc14_29.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc14_29.1: = bound_method %int_1.loc14_22, %impl.elem0.loc14_29.1 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc14_29.1: = specific_function %bound_method.loc14_29.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc14_29.1: init %i32 = call %specific_fn.loc14_29.1(%int_1.loc14_22) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc14_29.2: init %i32 = converted %int_1.loc14_22, %int.convert_checked.loc14_29.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %int_1.loc14_27: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2.loc14_30: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int_3.loc14_33: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc14_34.1: %tuple.type = tuple_literal (%int_1.loc14_27, %int_2.loc14_30, %int_3.loc14_33) +// CHECK:STDOUT: %impl.elem0.loc14_34.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc14_34.1: = bound_method %int_1.loc14_27, %impl.elem0.loc14_34.1 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc14_34.1: = specific_function %bound_method.loc14_34.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc14_34.1: init %i32 = call %specific_fn.loc14_34.1(%int_1.loc14_27) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_34.2: init %i32 = converted %int_1.loc14_27, %int.convert_checked.loc14_34.1 [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0.loc14: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc14_29.3: ref %i32 = array_index %a.var, %int_0.loc14 -// CHECK:STDOUT: %.loc14_29.4: init %i32 = initialize_from %.loc14_29.2 to %.loc14_29.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc14_29.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc14_29.2: = bound_method %int_2.loc14_25, %impl.elem0.loc14_29.2 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc14_29.2: = specific_function %bound_method.loc14_29.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc14_29.2: init %i32 = call %specific_fn.loc14_29.2(%int_2.loc14_25) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc14_29.5: init %i32 = converted %int_2.loc14_25, %int.convert_checked.loc14_29.2 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int_1.loc14_29: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc14_29.6: ref %i32 = array_index %a.var, %int_1.loc14_29 -// CHECK:STDOUT: %.loc14_29.7: init %i32 = initialize_from %.loc14_29.5 to %.loc14_29.6 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %impl.elem0.loc14_29.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc14_29.3: = bound_method %int_3.loc14_28, %impl.elem0.loc14_29.3 [concrete = constants.%Convert.bound.b30] -// CHECK:STDOUT: %specific_fn.loc14_29.3: = specific_function %bound_method.loc14_29.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc14_29.3: init %i32 = call %specific_fn.loc14_29.3(%int_3.loc14_28) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc14_29.8: init %i32 = converted %int_3.loc14_28, %int.convert_checked.loc14_29.3 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int_2.loc14_29: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc14_29.9: ref %i32 = array_index %a.var, %int_2.loc14_29 -// CHECK:STDOUT: %.loc14_29.10: init %i32 = initialize_from %.loc14_29.8 to %.loc14_29.9 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc14_29.11: init %array_type = array_init (%.loc14_29.4, %.loc14_29.7, %.loc14_29.10) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %.loc14_29.1, %.loc14_29.11 [concrete = constants.%array] +// CHECK:STDOUT: %.loc14_34.3: ref %i32 = array_index %a.var, %int_0.loc14 +// CHECK:STDOUT: %.loc14_34.4: init %i32 = initialize_from %.loc14_34.2 to %.loc14_34.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc14_34.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc14_34.2: = bound_method %int_2.loc14_30, %impl.elem0.loc14_34.2 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc14_34.2: = specific_function %bound_method.loc14_34.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc14_34.2: init %i32 = call %specific_fn.loc14_34.2(%int_2.loc14_30) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_34.5: init %i32 = converted %int_2.loc14_30, %int.convert_checked.loc14_34.2 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int_1.loc14_34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc14_34.6: ref %i32 = array_index %a.var, %int_1.loc14_34 +// CHECK:STDOUT: %.loc14_34.7: init %i32 = initialize_from %.loc14_34.5 to %.loc14_34.6 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %impl.elem0.loc14_34.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc14_34.3: = bound_method %int_3.loc14_33, %impl.elem0.loc14_34.3 [concrete = constants.%Convert.bound.b30] +// CHECK:STDOUT: %specific_fn.loc14_34.3: = specific_function %bound_method.loc14_34.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc14_34.3: init %i32 = call %specific_fn.loc14_34.3(%int_3.loc14_33) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc14_34.8: init %i32 = converted %int_3.loc14_33, %int.convert_checked.loc14_34.3 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int_2.loc14_34: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc14_34.9: ref %i32 = array_index %a.var, %int_2.loc14_34 +// CHECK:STDOUT: %.loc14_34.10: init %i32 = initialize_from %.loc14_34.8 to %.loc14_34.9 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc14_34.11: init %array_type = array_init (%.loc14_34.4, %.loc14_34.7, %.loc14_34.10) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %.loc14_34.1, %.loc14_34.11 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc14_3.2 -// CHECK:STDOUT: %.loc14_17: type = splice_block %array_type.loc14 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc14_22: type = splice_block %array_type.loc14 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %int_3.loc14_16: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type.loc14: type = array_type %int_3.loc14_16, %i32 [concrete = constants.%array_type] +// CHECK:STDOUT: %int_3.loc14_21: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc14: type = array_type %int_3.loc14_21, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: name_binding_decl { @@ -227,42 +227,42 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %.loc22_3.1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %int_1.loc22_22: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %int_2.loc22_25: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %int_3.loc22_28: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc22_29.1: %tuple.type = tuple_literal (%int_1.loc22_22, %int_2.loc22_25, %int_3.loc22_28) -// CHECK:STDOUT: %impl.elem0.loc22_29.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc22_29.1: = bound_method %int_1.loc22_22, %impl.elem0.loc22_29.1 [concrete = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %specific_fn.loc22_29.1: = specific_function %bound_method.loc22_29.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc22_29.1: init %i32 = call %specific_fn.loc22_29.1(%int_1.loc22_22) [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc22_29.2: init %i32 = converted %int_1.loc22_22, %int.convert_checked.loc22_29.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %int_1.loc22_27: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2.loc22_30: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int_3.loc22_33: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc22_34.1: %tuple.type = tuple_literal (%int_1.loc22_27, %int_2.loc22_30, %int_3.loc22_33) +// CHECK:STDOUT: %impl.elem0.loc22_34.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc22_34.1: = bound_method %int_1.loc22_27, %impl.elem0.loc22_34.1 [concrete = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %specific_fn.loc22_34.1: = specific_function %bound_method.loc22_34.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc22_34.1: init %i32 = call %specific_fn.loc22_34.1(%int_1.loc22_27) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc22_34.2: init %i32 = converted %int_1.loc22_27, %int.convert_checked.loc22_34.1 [concrete = constants.%int_1.5d2] // CHECK:STDOUT: %int_0.loc22: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc22_29.3: ref %i32 = array_index %a.var, %int_0.loc22 -// CHECK:STDOUT: %.loc22_29.4: init %i32 = initialize_from %.loc22_29.2 to %.loc22_29.3 [concrete = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc22_29.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc22_29.2: = bound_method %int_2.loc22_25, %impl.elem0.loc22_29.2 [concrete = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %specific_fn.loc22_29.2: = specific_function %bound_method.loc22_29.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc22_29.2: init %i32 = call %specific_fn.loc22_29.2(%int_2.loc22_25) [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc22_29.5: init %i32 = converted %int_2.loc22_25, %int.convert_checked.loc22_29.2 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %int_1.loc22_29: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc22_29.6: ref %i32 = array_index %a.var, %int_1.loc22_29 -// CHECK:STDOUT: %.loc22_29.7: init %i32 = initialize_from %.loc22_29.5 to %.loc22_29.6 [concrete = constants.%int_2.ef8] -// CHECK:STDOUT: %impl.elem0.loc22_29.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc22_29.3: = bound_method %int_3.loc22_28, %impl.elem0.loc22_29.3 [concrete = constants.%Convert.bound.b30] -// CHECK:STDOUT: %specific_fn.loc22_29.3: = specific_function %bound_method.loc22_29.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc22_29.3: init %i32 = call %specific_fn.loc22_29.3(%int_3.loc22_28) [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc22_29.8: init %i32 = converted %int_3.loc22_28, %int.convert_checked.loc22_29.3 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %int_2.loc22_29: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc22_29.9: ref %i32 = array_index %a.var, %int_2.loc22_29 -// CHECK:STDOUT: %.loc22_29.10: init %i32 = initialize_from %.loc22_29.8 to %.loc22_29.9 [concrete = constants.%int_3.822] -// CHECK:STDOUT: %.loc22_29.11: init %array_type = array_init (%.loc22_29.4, %.loc22_29.7, %.loc22_29.10) to %a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc22_3.2: init %array_type = converted %.loc22_29.1, %.loc22_29.11 [concrete = constants.%array] +// CHECK:STDOUT: %.loc22_34.3: ref %i32 = array_index %a.var, %int_0.loc22 +// CHECK:STDOUT: %.loc22_34.4: init %i32 = initialize_from %.loc22_34.2 to %.loc22_34.3 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc22_34.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc22_34.2: = bound_method %int_2.loc22_30, %impl.elem0.loc22_34.2 [concrete = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %specific_fn.loc22_34.2: = specific_function %bound_method.loc22_34.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc22_34.2: init %i32 = call %specific_fn.loc22_34.2(%int_2.loc22_30) [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc22_34.5: init %i32 = converted %int_2.loc22_30, %int.convert_checked.loc22_34.2 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %int_1.loc22_34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc22_34.6: ref %i32 = array_index %a.var, %int_1.loc22_34 +// CHECK:STDOUT: %.loc22_34.7: init %i32 = initialize_from %.loc22_34.5 to %.loc22_34.6 [concrete = constants.%int_2.ef8] +// CHECK:STDOUT: %impl.elem0.loc22_34.3: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc22_34.3: = bound_method %int_3.loc22_33, %impl.elem0.loc22_34.3 [concrete = constants.%Convert.bound.b30] +// CHECK:STDOUT: %specific_fn.loc22_34.3: = specific_function %bound_method.loc22_34.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc22_34.3: init %i32 = call %specific_fn.loc22_34.3(%int_3.loc22_33) [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc22_34.8: init %i32 = converted %int_3.loc22_33, %int.convert_checked.loc22_34.3 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %int_2.loc22_34: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc22_34.9: ref %i32 = array_index %a.var, %int_2.loc22_34 +// CHECK:STDOUT: %.loc22_34.10: init %i32 = initialize_from %.loc22_34.8 to %.loc22_34.9 [concrete = constants.%int_3.822] +// CHECK:STDOUT: %.loc22_34.11: init %array_type = array_init (%.loc22_34.4, %.loc22_34.7, %.loc22_34.10) to %a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc22_3.2: init %array_type = converted %.loc22_34.1, %.loc22_34.11 [concrete = constants.%array] // CHECK:STDOUT: assign %a.var, %.loc22_3.2 -// CHECK:STDOUT: %.loc22_17: type = splice_block %array_type.loc22 [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc22_22: type = splice_block %array_type.loc22 [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc22: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %int_3.loc22_16: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type.loc22: type = array_type %int_3.loc22_16, %i32 [concrete = constants.%array_type] +// CHECK:STDOUT: %int_3.loc22_21: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc22: type = array_type %int_3.loc22_21, %i32 [concrete = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, %a diff --git a/toolchain/check/testdata/index/fail_array_large_index.carbon b/toolchain/check/testdata/index/fail_array_large_index.carbon index 7f330810ca79..0f2eb9bf8c2c 100644 --- a/toolchain/check/testdata/index/fail_array_large_index.carbon +++ b/toolchain/check/testdata/index/fail_array_large_index.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_array_large_index.carbon -var a: [i32; 1] = (12,); +var a: array(i32, 1) = (12,); // CHECK:STDERR: fail_array_large_index.carbon:[[@LINE+4]]:16: error: array index `1` is past the end of type `[i32; 1]` [ArrayIndexOutOfBounds] // CHECK:STDERR: var b: i32 = a[1]; @@ -74,7 +74,7 @@ var c: i32 = a[0x7FFF_FFFF]; // CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] @@ -106,17 +106,17 @@ var c: i32 = a[0x7FFF_FFFF]; // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [concrete = constants.%int_12.6a3] -// CHECK:STDOUT: %.loc11_23.1: %tuple.type = tuple_literal (%int_12) +// CHECK:STDOUT: %.loc11_28.1: %tuple.type = tuple_literal (%int_12) // CHECK:STDOUT: %impl.elem0.loc11: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] // CHECK:STDOUT: %bound_method.loc11: = bound_method %int_12, %impl.elem0.loc11 [concrete = constants.%Convert.bound.221] // CHECK:STDOUT: %specific_fn.loc11: = specific_function %bound_method.loc11, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.9a9] // CHECK:STDOUT: %int.convert_checked.loc11: init %i32 = call %specific_fn.loc11(%int_12) [concrete = constants.%int_12.1e1] -// CHECK:STDOUT: %.loc11_23.2: init %i32 = converted %int_12, %int.convert_checked.loc11 [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %.loc11_28.2: init %i32 = converted %int_12, %int.convert_checked.loc11 [concrete = constants.%int_12.1e1] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_23.3: ref %i32 = array_index file.%a.var, %int_0 -// CHECK:STDOUT: %.loc11_23.4: init %i32 = initialize_from %.loc11_23.2 to %.loc11_23.3 [concrete = constants.%int_12.1e1] -// CHECK:STDOUT: %.loc11_23.5: init %array_type = array_init (%.loc11_23.4) to file.%a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_28.3: ref %i32 = array_index file.%a.var, %int_0 +// CHECK:STDOUT: %.loc11_28.4: init %i32 = initialize_from %.loc11_28.2 to %.loc11_28.3 [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %.loc11_28.5: init %array_type = array_init (%.loc11_28.4) to file.%a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_28.1, %.loc11_28.5 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref.loc17: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] diff --git a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon index 2d654a29c9ae..ac4d0245fc33 100644 --- a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_array_non_int_indexing.carbon -var a: [i32; 1] = (12,); +var a: array(i32, 1) = (12,); // CHECK:STDERR: fail_array_non_int_indexing.carbon:[[@LINE+7]]:16: error: cannot implicitly convert from `f64` to `i32` [ImplicitAsConversionFailure] // CHECK:STDERR: var b: i32 = a[2.6]; // CHECK:STDERR: ^~~ @@ -63,7 +63,7 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] @@ -85,17 +85,17 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [concrete = constants.%int_12.6a3] -// CHECK:STDOUT: %.loc11_23.1: %tuple.type = tuple_literal (%int_12) +// CHECK:STDOUT: %.loc11_28.1: %tuple.type = tuple_literal (%int_12) // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] // CHECK:STDOUT: %bound_method: = bound_method %int_12, %impl.elem0 [concrete = constants.%Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_12) [concrete = constants.%int_12.1e1] -// CHECK:STDOUT: %.loc11_23.2: init %i32 = converted %int_12, %int.convert_checked [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %.loc11_28.2: init %i32 = converted %int_12, %int.convert_checked [concrete = constants.%int_12.1e1] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_23.3: ref %i32 = array_index file.%a.var, %int_0 -// CHECK:STDOUT: %.loc11_23.4: init %i32 = initialize_from %.loc11_23.2 to %.loc11_23.3 [concrete = constants.%int_12.1e1] -// CHECK:STDOUT: %.loc11_23.5: init %array_type = array_init (%.loc11_23.4) to file.%a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_28.3: ref %i32 = array_index file.%a.var, %int_0 +// CHECK:STDOUT: %.loc11_28.4: init %i32 = initialize_from %.loc11_28.2 to %.loc11_28.3 [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %.loc11_28.5: init %array_type = array_init (%.loc11_28.4) to file.%a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_28.1, %.loc11_28.5 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %float: f64 = float_literal 2.6000000000000001 [concrete = constants.%float] diff --git a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon index d53f44fd4af7..4daab3c10925 100644 --- a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon +++ b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon -var a: [i32; 1] = (12,); +var a: array(i32, 1) = (12,); // CHECK:STDERR: fail_array_out_of_bound_access.carbon:[[@LINE+4]]:16: error: array index `1` is past the end of type `[i32; 1]` [ArrayIndexOutOfBounds] // CHECK:STDERR: var b: i32 = a[1]; // CHECK:STDERR: ^ @@ -62,7 +62,7 @@ var b: i32 = a[1]; // CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt // CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] @@ -84,17 +84,17 @@ var b: i32 = a[1]; // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [concrete = constants.%int_12.6a3] -// CHECK:STDOUT: %.loc11_23.1: %tuple.type = tuple_literal (%int_12) +// CHECK:STDOUT: %.loc11_28.1: %tuple.type = tuple_literal (%int_12) // CHECK:STDOUT: %impl.elem0.loc11: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] // CHECK:STDOUT: %bound_method.loc11: = bound_method %int_12, %impl.elem0.loc11 [concrete = constants.%Convert.bound.221] // CHECK:STDOUT: %specific_fn.loc11: = specific_function %bound_method.loc11, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.9a9] // CHECK:STDOUT: %int.convert_checked.loc11: init %i32 = call %specific_fn.loc11(%int_12) [concrete = constants.%int_12.1e1] -// CHECK:STDOUT: %.loc11_23.2: init %i32 = converted %int_12, %int.convert_checked.loc11 [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %.loc11_28.2: init %i32 = converted %int_12, %int.convert_checked.loc11 [concrete = constants.%int_12.1e1] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_23.3: ref %i32 = array_index file.%a.var, %int_0 -// CHECK:STDOUT: %.loc11_23.4: init %i32 = initialize_from %.loc11_23.2 to %.loc11_23.3 [concrete = constants.%int_12.1e1] -// CHECK:STDOUT: %.loc11_23.5: init %array_type = array_init (%.loc11_23.4) to file.%a.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_28.3: ref %i32 = array_index file.%a.var, %int_0 +// CHECK:STDOUT: %.loc11_28.4: init %i32 = initialize_from %.loc11_28.2 to %.loc11_28.3 [concrete = constants.%int_12.1e1] +// CHECK:STDOUT: %.loc11_28.5: init %array_type = array_init (%.loc11_28.4) to file.%a.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_28.1, %.loc11_28.5 [concrete = constants.%array] // CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] diff --git a/toolchain/check/testdata/index/fail_expr_category.carbon b/toolchain/check/testdata/index/fail_expr_category.carbon index 7df85bf40271..67dabc908b94 100644 --- a/toolchain/check/testdata/index/fail_expr_category.carbon +++ b/toolchain/check/testdata/index/fail_expr_category.carbon @@ -8,9 +8,9 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_expr_category.carbon -fn F() -> [i32; 3]; +fn F() -> array(i32, 3); -fn G(b: [i32; 3]) { +fn G(b: array(i32, 3)) { // Indexing an array value gives a value. // CHECK:STDERR: fail_expr_category.carbon:[[@LINE+4]]:18: error: cannot take the address of non-reference expression [AddrOfNonRef] // CHECK:STDERR: var pb: i32* = &b[0]; diff --git a/toolchain/check/testdata/index/fail_negative_indexing.carbon b/toolchain/check/testdata/index/fail_negative_indexing.carbon index b1a00bcce210..dbb571c24ef7 100644 --- a/toolchain/check/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/check/testdata/index/fail_negative_indexing.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_negative_indexing.carbon -var c: [i32; 2] = (42, 42); +var c: array(i32, 2) = (42, 42); // CHECK:STDERR: fail_negative_indexing.carbon:[[@LINE+4]]:16: error: array index `-10` is past the end of type `[i32; 2]` [ArrayIndexOutOfBounds] // CHECK:STDERR: var d: i32 = c[-10]; // CHECK:STDERR: ^~~ @@ -75,7 +75,7 @@ var d: i32 = c[-10]; // CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %c.patt // CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %array_type = var c -// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc11_20: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] @@ -96,27 +96,27 @@ var d: i32 = c[-10]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %int_42.loc11_20: Core.IntLiteral = int_value 42 [concrete = constants.%int_42.20e] -// CHECK:STDOUT: %int_42.loc11_24: Core.IntLiteral = int_value 42 [concrete = constants.%int_42.20e] -// CHECK:STDOUT: %.loc11_26.1: %tuple.type = tuple_literal (%int_42.loc11_20, %int_42.loc11_24) -// CHECK:STDOUT: %impl.elem0.loc11_26.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_26.1: = bound_method %int_42.loc11_20, %impl.elem0.loc11_26.1 [concrete = constants.%Convert.bound.132] -// CHECK:STDOUT: %specific_fn.loc11_26.1: = specific_function %bound_method.loc11_26.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.2f6] -// CHECK:STDOUT: %int.convert_checked.loc11_26.1: init %i32 = call %specific_fn.loc11_26.1(%int_42.loc11_20) [concrete = constants.%int_42.c68] -// CHECK:STDOUT: %.loc11_26.2: init %i32 = converted %int_42.loc11_20, %int.convert_checked.loc11_26.1 [concrete = constants.%int_42.c68] +// CHECK:STDOUT: %int_42.loc11_25: Core.IntLiteral = int_value 42 [concrete = constants.%int_42.20e] +// CHECK:STDOUT: %int_42.loc11_29: Core.IntLiteral = int_value 42 [concrete = constants.%int_42.20e] +// CHECK:STDOUT: %.loc11_31.1: %tuple.type = tuple_literal (%int_42.loc11_25, %int_42.loc11_29) +// CHECK:STDOUT: %impl.elem0.loc11_31.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_31.1: = bound_method %int_42.loc11_25, %impl.elem0.loc11_31.1 [concrete = constants.%Convert.bound.132] +// CHECK:STDOUT: %specific_fn.loc11_31.1: = specific_function %bound_method.loc11_31.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.2f6] +// CHECK:STDOUT: %int.convert_checked.loc11_31.1: init %i32 = call %specific_fn.loc11_31.1(%int_42.loc11_25) [concrete = constants.%int_42.c68] +// CHECK:STDOUT: %.loc11_31.2: init %i32 = converted %int_42.loc11_25, %int.convert_checked.loc11_31.1 [concrete = constants.%int_42.c68] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc11_26.3: ref %i32 = array_index file.%c.var, %int_0 -// CHECK:STDOUT: %.loc11_26.4: init %i32 = initialize_from %.loc11_26.2 to %.loc11_26.3 [concrete = constants.%int_42.c68] -// CHECK:STDOUT: %impl.elem0.loc11_26.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc11_26.2: = bound_method %int_42.loc11_24, %impl.elem0.loc11_26.2 [concrete = constants.%Convert.bound.132] -// CHECK:STDOUT: %specific_fn.loc11_26.2: = specific_function %bound_method.loc11_26.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.2f6] -// CHECK:STDOUT: %int.convert_checked.loc11_26.2: init %i32 = call %specific_fn.loc11_26.2(%int_42.loc11_24) [concrete = constants.%int_42.c68] -// CHECK:STDOUT: %.loc11_26.5: init %i32 = converted %int_42.loc11_24, %int.convert_checked.loc11_26.2 [concrete = constants.%int_42.c68] +// CHECK:STDOUT: %.loc11_31.3: ref %i32 = array_index file.%c.var, %int_0 +// CHECK:STDOUT: %.loc11_31.4: init %i32 = initialize_from %.loc11_31.2 to %.loc11_31.3 [concrete = constants.%int_42.c68] +// CHECK:STDOUT: %impl.elem0.loc11_31.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc11_31.2: = bound_method %int_42.loc11_29, %impl.elem0.loc11_31.2 [concrete = constants.%Convert.bound.132] +// CHECK:STDOUT: %specific_fn.loc11_31.2: = specific_function %bound_method.loc11_31.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.2f6] +// CHECK:STDOUT: %int.convert_checked.loc11_31.2: init %i32 = call %specific_fn.loc11_31.2(%int_42.loc11_29) [concrete = constants.%int_42.c68] +// CHECK:STDOUT: %.loc11_31.5: init %i32 = converted %int_42.loc11_29, %int.convert_checked.loc11_31.2 [concrete = constants.%int_42.c68] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc11_26.6: ref %i32 = array_index file.%c.var, %int_1 -// CHECK:STDOUT: %.loc11_26.7: init %i32 = initialize_from %.loc11_26.5 to %.loc11_26.6 [concrete = constants.%int_42.c68] -// CHECK:STDOUT: %.loc11_26.8: init %array_type = array_init (%.loc11_26.4, %.loc11_26.7) to file.%c.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_26.1, %.loc11_26.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_31.6: ref %i32 = array_index file.%c.var, %int_1 +// CHECK:STDOUT: %.loc11_31.7: init %i32 = initialize_from %.loc11_31.5 to %.loc11_31.6 [concrete = constants.%int_42.c68] +// CHECK:STDOUT: %.loc11_31.8: init %array_type = array_init (%.loc11_31.4, %.loc11_31.7) to file.%c.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_31.1, %.loc11_31.8 [concrete = constants.%array] // CHECK:STDOUT: assign file.%c.var, %.loc11_1 // CHECK:STDOUT: %c.ref: ref %array_type = name_ref c, file.%c // CHECK:STDOUT: %int_10: Core.IntLiteral = int_value 10 [concrete = constants.%int_10] diff --git a/toolchain/check/testdata/tuple/access/fail_non_tuple_access.carbon b/toolchain/check/testdata/tuple/access/fail_non_tuple_access.carbon index 3e05fdf72422..6740690d1f5c 100644 --- a/toolchain/check/testdata/tuple/access/fail_non_tuple_access.carbon +++ b/toolchain/check/testdata/tuple/access/fail_non_tuple_access.carbon @@ -15,7 +15,7 @@ fn Main() { // CHECK:STDERR: 0[1]; - var non_tuple: [i32; 2] = (5, 5); + var non_tuple: array(i32, 2) = (5, 5); // CHECK:STDERR: fail_non_tuple_access.carbon:[[@LINE+4]]:20: error: type `[i32; 2]` does not support tuple indexing; only tuples can be indexed that way [TupleIndexOnANonTupleType] // CHECK:STDERR: var first: i32 = non_tuple.0; // CHECK:STDERR: ^~~~~~~~~~~ @@ -77,29 +77,29 @@ fn Main() { // CHECK:STDOUT: %.loc18_3.1: %array_type = var_pattern %non_tuple.patt // CHECK:STDOUT: } // CHECK:STDOUT: %non_tuple.var: ref %array_type = var non_tuple -// CHECK:STDOUT: %int_5.loc18_30: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] -// CHECK:STDOUT: %int_5.loc18_33: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] -// CHECK:STDOUT: %.loc18_34.1: %tuple.type = tuple_literal (%int_5.loc18_30, %int_5.loc18_33) -// CHECK:STDOUT: %impl.elem0.loc18_34.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc18_34.1: = bound_method %int_5.loc18_30, %impl.elem0.loc18_34.1 [concrete = constants.%Convert.bound] -// CHECK:STDOUT: %specific_fn.loc18_34.1: = specific_function %bound_method.loc18_34.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc18_34.1: init %i32 = call %specific_fn.loc18_34.1(%int_5.loc18_30) [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc18_34.2: init %i32 = converted %int_5.loc18_30, %int.convert_checked.loc18_34.1 [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %int_5.loc18_35: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] +// CHECK:STDOUT: %int_5.loc18_38: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] +// CHECK:STDOUT: %.loc18_39.1: %tuple.type = tuple_literal (%int_5.loc18_35, %int_5.loc18_38) +// CHECK:STDOUT: %impl.elem0.loc18_39.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc18_39.1: = bound_method %int_5.loc18_35, %impl.elem0.loc18_39.1 [concrete = constants.%Convert.bound] +// CHECK:STDOUT: %specific_fn.loc18_39.1: = specific_function %bound_method.loc18_39.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc18_39.1: init %i32 = call %specific_fn.loc18_39.1(%int_5.loc18_35) [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc18_39.2: init %i32 = converted %int_5.loc18_35, %int.convert_checked.loc18_39.1 [concrete = constants.%int_5.0f6] // CHECK:STDOUT: %int_0.loc18: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc18_34.3: ref %i32 = array_index %non_tuple.var, %int_0.loc18 -// CHECK:STDOUT: %.loc18_34.4: init %i32 = initialize_from %.loc18_34.2 to %.loc18_34.3 [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %impl.elem0.loc18_34.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] -// CHECK:STDOUT: %bound_method.loc18_34.2: = bound_method %int_5.loc18_33, %impl.elem0.loc18_34.2 [concrete = constants.%Convert.bound] -// CHECK:STDOUT: %specific_fn.loc18_34.2: = specific_function %bound_method.loc18_34.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc18_34.2: init %i32 = call %specific_fn.loc18_34.2(%int_5.loc18_33) [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc18_34.5: init %i32 = converted %int_5.loc18_33, %int.convert_checked.loc18_34.2 [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc18_39.3: ref %i32 = array_index %non_tuple.var, %int_0.loc18 +// CHECK:STDOUT: %.loc18_39.4: init %i32 = initialize_from %.loc18_39.2 to %.loc18_39.3 [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %impl.elem0.loc18_39.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956] +// CHECK:STDOUT: %bound_method.loc18_39.2: = bound_method %int_5.loc18_38, %impl.elem0.loc18_39.2 [concrete = constants.%Convert.bound] +// CHECK:STDOUT: %specific_fn.loc18_39.2: = specific_function %bound_method.loc18_39.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc18_39.2: init %i32 = call %specific_fn.loc18_39.2(%int_5.loc18_38) [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc18_39.5: init %i32 = converted %int_5.loc18_38, %int.convert_checked.loc18_39.2 [concrete = constants.%int_5.0f6] // CHECK:STDOUT: %int_1.loc18: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %.loc18_34.6: ref %i32 = array_index %non_tuple.var, %int_1.loc18 -// CHECK:STDOUT: %.loc18_34.7: init %i32 = initialize_from %.loc18_34.5 to %.loc18_34.6 [concrete = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc18_34.8: init %array_type = array_init (%.loc18_34.4, %.loc18_34.7) to %non_tuple.var [concrete = constants.%array] -// CHECK:STDOUT: %.loc18_3.2: init %array_type = converted %.loc18_34.1, %.loc18_34.8 [concrete = constants.%array] +// CHECK:STDOUT: %.loc18_39.6: ref %i32 = array_index %non_tuple.var, %int_1.loc18 +// CHECK:STDOUT: %.loc18_39.7: init %i32 = initialize_from %.loc18_39.5 to %.loc18_39.6 [concrete = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc18_39.8: init %array_type = array_init (%.loc18_39.4, %.loc18_39.7) to %non_tuple.var [concrete = constants.%array] +// CHECK:STDOUT: %.loc18_3.2: init %array_type = converted %.loc18_39.1, %.loc18_39.8 [concrete = constants.%array] // CHECK:STDOUT: assign %non_tuple.var, %.loc18_3.2 -// CHECK:STDOUT: %.loc18_25: type = splice_block %array_type [concrete = constants.%array_type] { +// CHECK:STDOUT: %.loc18_30: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] // CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] diff --git a/toolchain/diagnostics/diagnostic_kind.def b/toolchain/diagnostics/diagnostic_kind.def index e6654c22dd1f..9a58df5bf90e 100644 --- a/toolchain/diagnostics/diagnostic_kind.def +++ b/toolchain/diagnostics/diagnostic_kind.def @@ -76,7 +76,7 @@ CARBON_DIAGNOSTIC_KIND(WrongRealLiteralExponent) // ============================================================================ CARBON_DIAGNOSTIC_KIND(BinaryOperatorRequiresWhitespace) -CARBON_DIAGNOSTIC_KIND(ExpectedArraySemi) +CARBON_DIAGNOSTIC_KIND(ExpectedArrayComma) CARBON_DIAGNOSTIC_KIND(ExpectedCloseSymbol) CARBON_DIAGNOSTIC_KIND(ExpectedCodeBlock) CARBON_DIAGNOSTIC_KIND(ExpectedExpr) diff --git a/toolchain/lex/lex.cpp b/toolchain/lex/lex.cpp index eb73ddddd5f0..e7e098750c59 100644 --- a/toolchain/lex/lex.cpp +++ b/toolchain/lex/lex.cpp @@ -525,7 +525,7 @@ CARBON_DISPATCH_LEX_TOKEN(LexHash) CARBON_DISPATCH_LEX_TOKEN(LexNumericLiteral) CARBON_DISPATCH_LEX_TOKEN(LexStringLiteral) -// A custom dispatch functions that pre-select the symbol token to lex. +// A set of custom dispatch functions that pre-select the symbol token to lex. #define CARBON_DISPATCH_LEX_SYMBOL_TOKEN(LexMethod) \ static auto Dispatch##LexMethod##SymbolToken( \ Lexer& lexer, llvm::StringRef source_text, ssize_t position) -> void { \ diff --git a/toolchain/lex/lex.h b/toolchain/lex/lex.h index 9e901148e2d3..22019d45466d 100644 --- a/toolchain/lex/lex.h +++ b/toolchain/lex/lex.h @@ -16,7 +16,8 @@ namespace Carbon::Lex { // // The provided source buffer must outlive any returned `TokenizedBuffer` // which will refer into the source. -auto Lex(SharedValueStores& value_stores, SourceBuffer& source, +auto Lex(SharedValueStores& value_stores, + SourceBuffer& source [[clang::lifetimebound]], DiagnosticConsumer& consumer) -> TokenizedBuffer; } // namespace Carbon::Lex diff --git a/toolchain/lex/testdata/numeric_literals.carbon b/toolchain/lex/testdata/numeric_literals.carbon index d92f14ac43de..db92d8ee60a1 100644 --- a/toolchain/lex/testdata/numeric_literals.carbon +++ b/toolchain/lex/testdata/numeric_literals.carbon @@ -14,79 +14,81 @@ fn F() { -// CHECK:STDOUT: - { index: 1, kind: "Fn", line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: "fn", has_leading_space: true } -// CHECK:STDOUT: - { index: 2, kind: "Identifier", line: {{ *}}[[@LINE-2]], column: 4, indent: 1, spelling: "F", identifier: 0, has_leading_space: true } -// CHECK:STDOUT: - { index: 3, kind: "OpenParen", line: {{ *}}[[@LINE-3]], column: 5, indent: 1, spelling: "(", closing_token: 4 } -// CHECK:STDOUT: - { index: 4, kind: "CloseParen", line: {{ *}}[[@LINE-4]], column: 6, indent: 1, spelling: ")", opening_token: 3 } -// CHECK:STDOUT: - { index: 5, kind: "OpenCurlyBrace", line: {{ *}}[[@LINE-5]], column: 8, indent: 1, spelling: "{", closing_token: 54, has_leading_space: true } +// CHECK:STDOUT: - { index: 1, kind: "Fn", line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: "fn", has_leading_space: true } +// CHECK:STDOUT: - { index: 2, kind: "Identifier", line: {{ *}}[[@LINE-2]], column: 4, indent: 1, spelling: "F", identifier: 0, has_leading_space: true } +// CHECK:STDOUT: - { index: 3, kind: "OpenParen", line: {{ *}}[[@LINE-3]], column: 5, indent: 1, spelling: "(", closing_token: 4 } +// CHECK:STDOUT: - { index: 4, kind: "CloseParen", line: {{ *}}[[@LINE-4]], column: 6, indent: 1, spelling: ")", opening_token: 3 } +// CHECK:STDOUT: - { index: 5, kind: "OpenCurlyBrace", line: {{ *}}[[@LINE-5]], column: 8, indent: 1, spelling: "{", closing_token: 56, has_leading_space: true } // 8 and 9 trigger special behavior in APInt when mishandling signed versus // unsigned, so we pay extra attention to those. - var ints: [i32; 5] = ( - // CHECK:STDOUT: - { index: 6, kind: "Var", line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: "var", has_leading_space: true } - // CHECK:STDOUT: - { index: 7, kind: "Identifier", line: {{ *}}[[@LINE-2]], column: 7, indent: 3, spelling: "ints", identifier: 1, has_leading_space: true } - // CHECK:STDOUT: - { index: 8, kind: "Colon", line: {{ *}}[[@LINE-3]], column: 11, indent: 3, spelling: ":" } - // CHECK:STDOUT: - { index: 9, kind: "OpenSquareBracket", line: {{ *}}[[@LINE-4]], column: 13, indent: 3, spelling: "[", closing_token: 13, has_leading_space: true } - // CHECK:STDOUT: - { index: 10, kind: "IntTypeLiteral", line: {{ *}}[[@LINE-5]], column: 14, indent: 3, spelling: "i32" } - // CHECK:STDOUT: - { index: 11, kind: "Semi", line: {{ *}}[[@LINE-6]], column: 17, indent: 3, spelling: ";" } - // CHECK:STDOUT: - { index: 12, kind: "IntLiteral", line: {{ *}}[[@LINE-7]], column: 19, indent: 3, spelling: "5", value: "5", has_leading_space: true } - // CHECK:STDOUT: - { index: 13, kind: "CloseSquareBracket", line: {{ *}}[[@LINE-8]], column: 20, indent: 3, spelling: "]", opening_token: 9 } - // CHECK:STDOUT: - { index: 14, kind: "Equal", line: {{ *}}[[@LINE-9]], column: 22, indent: 3, spelling: "=", has_leading_space: true } - // CHECK:STDOUT: - { index: 15, kind: "OpenParen", line: {{ *}}[[@LINE-10]], column: 24, indent: 3, spelling: "(", closing_token: 26, has_leading_space: true } + var ints: array(i32, 5) = ( + // CHECK:STDOUT: - { index: 6, kind: "Var", line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: "var", has_leading_space: true } + // CHECK:STDOUT: - { index: 7, kind: "Identifier", line: {{ *}}[[@LINE-2]], column: 7, indent: 3, spelling: "ints", identifier: 1, has_leading_space: true } + // CHECK:STDOUT: - { index: 8, kind: "Colon", line: {{ *}}[[@LINE-3]], column: 11, indent: 3, spelling: ":" } + // CHECK:STDOUT: - { index: 9, kind: "Array", line: {{ *}}[[@LINE-4]], column: 13, indent: 3, spelling: "array", has_leading_space: true } + // CHECK:STDOUT: - { index: 10, kind: "OpenParen", line: {{ *}}[[@LINE-5]], column: 18, indent: 3, spelling: "(", closing_token: 14 } + // CHECK:STDOUT: - { index: 11, kind: "IntTypeLiteral", line: {{ *}}[[@LINE-6]], column: 19, indent: 3, spelling: "i32" } + // CHECK:STDOUT: - { index: 12, kind: "Comma", line: {{ *}}[[@LINE-7]], column: 22, indent: 3, spelling: "," } + // CHECK:STDOUT: - { index: 13, kind: "IntLiteral", line: {{ *}}[[@LINE-8]], column: 24, indent: 3, spelling: "5", value: "5", has_leading_space: true } + // CHECK:STDOUT: - { index: 14, kind: "CloseParen", line: {{ *}}[[@LINE-9]], column: 25, indent: 3, spelling: ")", opening_token: 10 } + // CHECK:STDOUT: - { index: 15, kind: "Equal", line: {{ *}}[[@LINE-10]], column: 27, indent: 3, spelling: "=", has_leading_space: true } + // CHECK:STDOUT: - { index: 16, kind: "OpenParen", line: {{ *}}[[@LINE-11]], column: 29, indent: 3, spelling: "(", closing_token: 27, has_leading_space: true } 8, - // CHECK:STDOUT: - { index: 16, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "8", value: "8", has_leading_space: true } - // CHECK:STDOUT: - { index: 17, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 6, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 17, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "8", value: "8", has_leading_space: true } + // CHECK:STDOUT: - { index: 18, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 6, indent: 5, spelling: "," } 9, - // CHECK:STDOUT: - { index: 18, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "9", value: "9", has_leading_space: true } - // CHECK:STDOUT: - { index: 19, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 6, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 19, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "9", value: "9", has_leading_space: true } + // CHECK:STDOUT: - { index: 20, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 6, indent: 5, spelling: "," } 0x8, - // CHECK:STDOUT: - { index: 20, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "0x8", value: "8", has_leading_space: true } - // CHECK:STDOUT: - { index: 21, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 21, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "0x8", value: "8", has_leading_space: true } + // CHECK:STDOUT: - { index: 22, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: "," } 0b1000, - // CHECK:STDOUT: - { index: 22, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "0b1000", value: "8", has_leading_space: true } - // CHECK:STDOUT: - { index: 23, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 11, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 23, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "0b1000", value: "8", has_leading_space: true } + // CHECK:STDOUT: - { index: 24, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 11, indent: 5, spelling: "," } 39999999999999999993, - // CHECK:STDOUT: - { index: 24, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "39999999999999999993", value: "39999999999999999993", has_leading_space: true } - // CHECK:STDOUT: - { index: 25, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 25, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 25, kind: "IntLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "39999999999999999993", value: "39999999999999999993", has_leading_space: true } + // CHECK:STDOUT: - { index: 26, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 25, indent: 5, spelling: "," } ); - // CHECK:STDOUT: - { index: 26, kind: "CloseParen", line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: ")", opening_token: 15, has_leading_space: true } - // CHECK:STDOUT: - { index: 27, kind: "Semi", line: {{ *}}[[@LINE-2]], column: 4, indent: 3, spelling: ";" } - var floats: [f64; 7] = ( - // CHECK:STDOUT: - { index: 28, kind: "Var", line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: "var", has_leading_space: true } - // CHECK:STDOUT: - { index: 29, kind: "Identifier", line: {{ *}}[[@LINE-2]], column: 7, indent: 3, spelling: "floats", identifier: 2, has_leading_space: true } - // CHECK:STDOUT: - { index: 30, kind: "Colon", line: {{ *}}[[@LINE-3]], column: 13, indent: 3, spelling: ":" } - // CHECK:STDOUT: - { index: 31, kind: "OpenSquareBracket", line: {{ *}}[[@LINE-4]], column: 15, indent: 3, spelling: "[", closing_token: 35, has_leading_space: true } - // CHECK:STDOUT: - { index: 32, kind: "FloatTypeLiteral", line: {{ *}}[[@LINE-5]], column: 16, indent: 3, spelling: "f64" } - // CHECK:STDOUT: - { index: 33, kind: "Semi", line: {{ *}}[[@LINE-6]], column: 19, indent: 3, spelling: ";" } - // CHECK:STDOUT: - { index: 34, kind: "IntLiteral", line: {{ *}}[[@LINE-7]], column: 21, indent: 3, spelling: "7", value: "7", has_leading_space: true } - // CHECK:STDOUT: - { index: 35, kind: "CloseSquareBracket", line: {{ *}}[[@LINE-8]], column: 22, indent: 3, spelling: "]", opening_token: 31 } - // CHECK:STDOUT: - { index: 36, kind: "Equal", line: {{ *}}[[@LINE-9]], column: 24, indent: 3, spelling: "=", has_leading_space: true } - // CHECK:STDOUT: - { index: 37, kind: "OpenParen", line: {{ *}}[[@LINE-10]], column: 26, indent: 3, spelling: "(", closing_token: 52, has_leading_space: true } + // CHECK:STDOUT: - { index: 27, kind: "CloseParen", line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: ")", opening_token: 16, has_leading_space: true } + // CHECK:STDOUT: - { index: 28, kind: "Semi", line: {{ *}}[[@LINE-2]], column: 4, indent: 3, spelling: ";" } + var floats: array(f64, 7) = ( + // CHECK:STDOUT: - { index: 29, kind: "Var", line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: "var", has_leading_space: true } + // CHECK:STDOUT: - { index: 30, kind: "Identifier", line: {{ *}}[[@LINE-2]], column: 7, indent: 3, spelling: "floats", identifier: 2, has_leading_space: true } + // CHECK:STDOUT: - { index: 31, kind: "Colon", line: {{ *}}[[@LINE-3]], column: 13, indent: 3, spelling: ":" } + // CHECK:STDOUT: - { index: 32, kind: "Array", line: {{ *}}[[@LINE-4]], column: 15, indent: 3, spelling: "array", has_leading_space: true } + // CHECK:STDOUT: - { index: 33, kind: "OpenParen", line: {{ *}}[[@LINE-5]], column: 20, indent: 3, spelling: "(", closing_token: 37 } + // CHECK:STDOUT: - { index: 34, kind: "FloatTypeLiteral", line: {{ *}}[[@LINE-6]], column: 21, indent: 3, spelling: "f64" } + // CHECK:STDOUT: - { index: 35, kind: "Comma", line: {{ *}}[[@LINE-7]], column: 24, indent: 3, spelling: "," } + // CHECK:STDOUT: - { index: 36, kind: "IntLiteral", line: {{ *}}[[@LINE-8]], column: 26, indent: 3, spelling: "7", value: "7", has_leading_space: true } + // CHECK:STDOUT: - { index: 37, kind: "CloseParen", line: {{ *}}[[@LINE-9]], column: 27, indent: 3, spelling: ")", opening_token: 33 } + // CHECK:STDOUT: - { index: 38, kind: "Equal", line: {{ *}}[[@LINE-10]], column: 29, indent: 3, spelling: "=", has_leading_space: true } + // CHECK:STDOUT: - { index: 39, kind: "OpenParen", line: {{ *}}[[@LINE-11]], column: 31, indent: 3, spelling: "(", closing_token: 54, has_leading_space: true } 0.9, - // CHECK:STDOUT: - { index: 38, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "0.9", value: "9*10^-1", has_leading_space: true } - // CHECK:STDOUT: - { index: 39, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 40, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "0.9", value: "9*10^-1", has_leading_space: true } + // CHECK:STDOUT: - { index: 41, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: "," } 8.0, - // CHECK:STDOUT: - { index: 40, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "8.0", value: "80*10^-1", has_leading_space: true } - // CHECK:STDOUT: - { index: 41, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 42, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "8.0", value: "80*10^-1", has_leading_space: true } + // CHECK:STDOUT: - { index: 43, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: "," } 80.0, - // CHECK:STDOUT: - { index: 42, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "80.0", value: "800*10^-1", has_leading_space: true } - // CHECK:STDOUT: - { index: 43, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 9, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 44, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "80.0", value: "800*10^-1", has_leading_space: true } + // CHECK:STDOUT: - { index: 45, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 9, indent: 5, spelling: "," } 1.0e7, - // CHECK:STDOUT: - { index: 44, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "1.0e7", value: "10*10^6", has_leading_space: true } - // CHECK:STDOUT: - { index: 45, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 10, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 46, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "1.0e7", value: "10*10^6", has_leading_space: true } + // CHECK:STDOUT: - { index: 47, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 10, indent: 5, spelling: "," } 1.0e8, - // CHECK:STDOUT: - { index: 46, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "1.0e8", value: "10*10^7", has_leading_space: true } - // CHECK:STDOUT: - { index: 47, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 10, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 48, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "1.0e8", value: "10*10^7", has_leading_space: true } + // CHECK:STDOUT: - { index: 49, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 10, indent: 5, spelling: "," } 1.0e-8, - // CHECK:STDOUT: - { index: 48, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "1.0e-8", value: "10*10^-9", has_leading_space: true } - // CHECK:STDOUT: - { index: 49, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 11, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 50, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "1.0e-8", value: "10*10^-9", has_leading_space: true } + // CHECK:STDOUT: - { index: 51, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 11, indent: 5, spelling: "," } 39999999999999999993.0e39999999999999999993, - // CHECK:STDOUT: - { index: 50, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "39999999999999999993.0e39999999999999999993", value: "399999999999999999930*10^39999999999999999992", has_leading_space: true } - // CHECK:STDOUT: - { index: 51, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 48, indent: 5, spelling: "," } + // CHECK:STDOUT: - { index: 52, kind: "RealLiteral", line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: "39999999999999999993.0e39999999999999999993", value: "399999999999999999930*10^39999999999999999992", has_leading_space: true } + // CHECK:STDOUT: - { index: 53, kind: "Comma", line: {{ *}}[[@LINE-2]], column: 48, indent: 5, spelling: "," } ); - // CHECK:STDOUT: - { index: 52, kind: "CloseParen", line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: ")", opening_token: 37, has_leading_space: true } - // CHECK:STDOUT: - { index: 53, kind: "Semi", line: {{ *}}[[@LINE-2]], column: 4, indent: 3, spelling: ";" } + // CHECK:STDOUT: - { index: 54, kind: "CloseParen", line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: ")", opening_token: 39, has_leading_space: true } + // CHECK:STDOUT: - { index: 55, kind: "Semi", line: {{ *}}[[@LINE-2]], column: 4, indent: 3, spelling: ";" } } -// CHECK:STDOUT: - { index: 54, kind: "CloseCurlyBrace", line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: "}", opening_token: 5, has_leading_space: true } +// CHECK:STDOUT: - { index: 56, kind: "CloseCurlyBrace", line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: "}", opening_token: 5, has_leading_space: true } // --- fail_binary_real.carbon diff --git a/toolchain/lex/token_kind.def b/toolchain/lex/token_kind.def index 85abd21abfae..4699203a7562 100644 --- a/toolchain/lex/token_kind.def +++ b/toolchain/lex/token_kind.def @@ -169,6 +169,7 @@ CARBON_KEYWORD_TOKEN(Abstract, "abstract") CARBON_KEYWORD_TOKEN(Addr, "addr") CARBON_TOKEN_WITH_VIRTUAL_NODE( CARBON_KEYWORD_TOKEN(And, "and")) +CARBON_KEYWORD_TOKEN(Array, "array") CARBON_KEYWORD_TOKEN(As, "as") CARBON_KEYWORD_TOKEN(Auto, "auto") CARBON_KEYWORD_TOKEN(Bool, "bool") diff --git a/toolchain/lex/tokenized_buffer.h b/toolchain/lex/tokenized_buffer.h index 73ef4b62990e..4de067d398f3 100644 --- a/toolchain/lex/tokenized_buffer.h +++ b/toolchain/lex/tokenized_buffer.h @@ -447,8 +447,9 @@ class TokenizedBuffer : public Printable { // The constructor is merely responsible for trivial initialization of // members. A working object of this type is built with `Lex::Lex` so that its // return can indicate if an error was encountered while lexing. - explicit TokenizedBuffer(SharedValueStores& value_stores, - SourceBuffer& source) + explicit TokenizedBuffer(SharedValueStores& value_stores + [[clang::lifetimebound]], + SourceBuffer& source [[clang::lifetimebound]]) : value_stores_(&value_stores), source_(&source) {} auto FindLineIndex(int32_t byte_offset) const -> LineIndex; diff --git a/toolchain/lower/testdata/array/array_in_place.carbon b/toolchain/lower/testdata/array/array_in_place.carbon index 0348b647585c..31b375e7e7cb 100644 --- a/toolchain/lower/testdata/array/array_in_place.carbon +++ b/toolchain/lower/testdata/array/array_in_place.carbon @@ -11,7 +11,7 @@ fn F() -> (i32, i32, i32); fn G() { - var v: [(i32, i32, i32); 2] = (F(), F()); + var v: array((i32, i32, i32), 2) = (F(), F()); } // CHECK:STDOUT: ; ModuleID = 'array_in_place.carbon' @@ -23,10 +23,10 @@ fn G() { // CHECK:STDOUT: entry: // CHECK:STDOUT: %v.var = alloca [2 x { i32, i32, i32 }], align 8, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 24, ptr %v.var), !dbg !7 -// CHECK:STDOUT: %.loc14_42.2.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i64 0, !dbg !8 -// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_42.2.array.index), !dbg !9 -// CHECK:STDOUT: %.loc14_42.4.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i64 1, !dbg !8 -// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_42.4.array.index), !dbg !10 +// CHECK:STDOUT: %.loc14_47.2.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i64 0, !dbg !8 +// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_47.2.array.index), !dbg !9 +// CHECK:STDOUT: %.loc14_47.4.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i64 1, !dbg !8 +// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_47.4.array.index), !dbg !10 // CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -46,7 +46,7 @@ fn G() { // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 33, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 34, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 39, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 38, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 39, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 44, scope: !4) // CHECK:STDOUT: !11 = !DILocation(line: 13, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/array/assign_return_value.carbon b/toolchain/lower/testdata/array/assign_return_value.carbon index 0d8d8b99c3b2..d5b1e2c8c7e9 100644 --- a/toolchain/lower/testdata/array/assign_return_value.carbon +++ b/toolchain/lower/testdata/array/assign_return_value.carbon @@ -11,7 +11,7 @@ fn F() -> (i32, i32) { return (12, 24); } fn Run() { - var t: [i32; 2] = F(); + var t: array(i32, 2) = F(); } // CHECK:STDOUT: ; ModuleID = 'assign_return_value.carbon' @@ -31,16 +31,16 @@ fn Run() { // CHECK:STDOUT: entry: // CHECK:STDOUT: %t.var = alloca [2 x i32], align 4, !dbg !10 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %t.var), !dbg !10 -// CHECK:STDOUT: %.loc14_23.1.temp = alloca { i32, i32 }, align 8, !dbg !11 -// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_23.1.temp), !dbg !11 -// CHECK:STDOUT: %tuple.elem0.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_23.1.temp, i32 0, i32 0, !dbg !11 -// CHECK:STDOUT: %.loc14_23.3 = load i32, ptr %tuple.elem0.tuple.elem, align 4, !dbg !11 -// CHECK:STDOUT: %.loc14_23.4.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i64 0, !dbg !11 -// CHECK:STDOUT: store i32 %.loc14_23.3, ptr %.loc14_23.4.array.index, align 4, !dbg !11 -// CHECK:STDOUT: %tuple.elem1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_23.1.temp, i32 0, i32 1, !dbg !11 -// CHECK:STDOUT: %.loc14_23.6 = load i32, ptr %tuple.elem1.tuple.elem, align 4, !dbg !11 -// CHECK:STDOUT: %.loc14_23.7.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i64 1, !dbg !11 -// CHECK:STDOUT: store i32 %.loc14_23.6, ptr %.loc14_23.7.array.index, align 4, !dbg !11 +// CHECK:STDOUT: %.loc14_28.1.temp = alloca { i32, i32 }, align 8, !dbg !11 +// CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_28.1.temp), !dbg !11 +// CHECK:STDOUT: %tuple.elem0.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_28.1.temp, i32 0, i32 0, !dbg !11 +// CHECK:STDOUT: %.loc14_28.3 = load i32, ptr %tuple.elem0.tuple.elem, align 4, !dbg !11 +// CHECK:STDOUT: %.loc14_28.4.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i64 0, !dbg !11 +// CHECK:STDOUT: store i32 %.loc14_28.3, ptr %.loc14_28.4.array.index, align 4, !dbg !11 +// CHECK:STDOUT: %tuple.elem1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_28.1.temp, i32 0, i32 1, !dbg !11 +// CHECK:STDOUT: %.loc14_28.6 = load i32, ptr %tuple.elem1.tuple.elem, align 4, !dbg !11 +// CHECK:STDOUT: %.loc14_28.7.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i64 1, !dbg !11 +// CHECK:STDOUT: store i32 %.loc14_28.6, ptr %.loc14_28.7.array.index, align 4, !dbg !11 // CHECK:STDOUT: ret void, !dbg !12 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -67,5 +67,5 @@ fn Run() { // CHECK:STDOUT: !8 = !DILocation(line: 11, column: 24, scope: !4) // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !9) -// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 21, scope: !9) +// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 26, scope: !9) // CHECK:STDOUT: !12 = !DILocation(line: 13, column: 1, scope: !9) diff --git a/toolchain/lower/testdata/array/base.carbon b/toolchain/lower/testdata/array/base.carbon index b2a0c25c83c5..7d024dac6a24 100644 --- a/toolchain/lower/testdata/array/base.carbon +++ b/toolchain/lower/testdata/array/base.carbon @@ -9,11 +9,11 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/array/base.carbon fn Run() { - var a: [i32; 1] = (1,); - var b: [f64; 2] = (11.1, 2.2,); - var c: [(); 5] = ((), (), (), (), (),); + var a: array(i32, 1) = (1,); + var b: array(f64, 2) = (11.1, 2.2,); + var c: array((), 5) = ((), (), (), (), (),); var d: (i32, i32, i32) = (1, 2, 3); - var e: [i32; 3] = d; + var e: array(i32, 3) = d; } // CHECK:STDOUT: ; ModuleID = 'base.carbon' @@ -32,18 +32,18 @@ fn Run() { // CHECK:STDOUT: %d.var = alloca { i32, i32, i32 }, align 8, !dbg !7 // CHECK:STDOUT: %e.var = alloca [3 x i32], align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %a.var), !dbg !7 -// CHECK:STDOUT: %.loc12_24.3.array.index = getelementptr inbounds [1 x i32], ptr %a.var, i32 0, i64 0, !dbg !8 +// CHECK:STDOUT: %.loc12_29.3.array.index = getelementptr inbounds [1 x i32], ptr %a.var, i32 0, i64 0, !dbg !8 // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @array.237.loc12_3.2, i64 4, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 16, ptr %b.var), !dbg !7 -// CHECK:STDOUT: %.loc13_32.2.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 0, !dbg !9 -// CHECK:STDOUT: %.loc13_32.4.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 1, !dbg !9 +// CHECK:STDOUT: %.loc13_37.2.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 0, !dbg !9 +// CHECK:STDOUT: %.loc13_37.4.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 1, !dbg !9 // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %b.var, ptr align 8 @array.6a2.loc13_3.2, i64 16, i1 false), !dbg !10 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 0, ptr %c.var), !dbg !7 -// CHECK:STDOUT: %.loc14_40.2.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 0, !dbg !11 -// CHECK:STDOUT: %.loc14_40.4.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 1, !dbg !11 -// CHECK:STDOUT: %.loc14_40.6.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 2, !dbg !11 -// CHECK:STDOUT: %.loc14_40.8.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 3, !dbg !11 -// CHECK:STDOUT: %.loc14_40.10.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 4, !dbg !11 +// CHECK:STDOUT: %.loc14_45.2.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 0, !dbg !11 +// CHECK:STDOUT: %.loc14_45.4.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 1, !dbg !11 +// CHECK:STDOUT: %.loc14_45.6.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 2, !dbg !11 +// CHECK:STDOUT: %.loc14_45.8.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 3, !dbg !11 +// CHECK:STDOUT: %.loc14_45.10.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 4, !dbg !11 // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @array.1cb.loc14_3.2, i64 0, i1 false), !dbg !12 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 12, ptr %d.var), !dbg !7 // CHECK:STDOUT: %tuple.elem0.loc15.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0, !dbg !13 @@ -52,17 +52,17 @@ fn Run() { // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %d.var, ptr align 4 @tuple.loc15_3.2, i64 12, i1 false), !dbg !14 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 12, ptr %e.var), !dbg !7 // CHECK:STDOUT: %tuple.elem0.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0, !dbg !15 -// CHECK:STDOUT: %.loc16_21.1 = load i32, ptr %tuple.elem0.loc16.tuple.elem, align 4, !dbg !15 -// CHECK:STDOUT: %.loc16_21.2.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 0, !dbg !15 -// CHECK:STDOUT: store i32 %.loc16_21.1, ptr %.loc16_21.2.array.index, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_26.1 = load i32, ptr %tuple.elem0.loc16.tuple.elem, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_26.2.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 0, !dbg !15 +// CHECK:STDOUT: store i32 %.loc16_26.1, ptr %.loc16_26.2.array.index, align 4, !dbg !15 // CHECK:STDOUT: %tuple.elem1.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1, !dbg !15 -// CHECK:STDOUT: %.loc16_21.4 = load i32, ptr %tuple.elem1.loc16.tuple.elem, align 4, !dbg !15 -// CHECK:STDOUT: %.loc16_21.5.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 1, !dbg !15 -// CHECK:STDOUT: store i32 %.loc16_21.4, ptr %.loc16_21.5.array.index, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_26.4 = load i32, ptr %tuple.elem1.loc16.tuple.elem, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_26.5.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 1, !dbg !15 +// CHECK:STDOUT: store i32 %.loc16_26.4, ptr %.loc16_26.5.array.index, align 4, !dbg !15 // CHECK:STDOUT: %tuple.elem2.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2, !dbg !15 -// CHECK:STDOUT: %.loc16_21.7 = load i32, ptr %tuple.elem2.loc16.tuple.elem, align 4, !dbg !15 -// CHECK:STDOUT: %.loc16_21.8.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 2, !dbg !15 -// CHECK:STDOUT: store i32 %.loc16_21.7, ptr %.loc16_21.8.array.index, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_26.7 = load i32, ptr %tuple.elem2.loc16.tuple.elem, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_26.8.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 2, !dbg !15 +// CHECK:STDOUT: store i32 %.loc16_26.7, ptr %.loc16_26.8.array.index, align 4, !dbg !15 // CHECK:STDOUT: ret void, !dbg !16 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -91,12 +91,12 @@ fn Run() { // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 21, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 21, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 26, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 26, scope: !4) // CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 20, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 25, scope: !4) // CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !4) // CHECK:STDOUT: !13 = !DILocation(line: 15, column: 28, scope: !4) // CHECK:STDOUT: !14 = !DILocation(line: 15, column: 3, scope: !4) -// CHECK:STDOUT: !15 = !DILocation(line: 16, column: 21, scope: !4) +// CHECK:STDOUT: !15 = !DILocation(line: 16, column: 26, scope: !4) // CHECK:STDOUT: !16 = !DILocation(line: 11, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/array/field.carbon b/toolchain/lower/testdata/array/field.carbon index ee977c9fe180..7f617d56ee7c 100644 --- a/toolchain/lower/testdata/array/field.carbon +++ b/toolchain/lower/testdata/array/field.carbon @@ -9,7 +9,7 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/array/field.carbon class A { - var v: [i32; 2]; + var v: array(i32, 2); // TODO: The LLVM IR we create for this crashes LLVM instruction selection. // The gep indexes are completely bogus. diff --git a/toolchain/lower/testdata/array/function_param.carbon b/toolchain/lower/testdata/array/function_param.carbon index 910e17d75867..1dce624f4488 100644 --- a/toolchain/lower/testdata/array/function_param.carbon +++ b/toolchain/lower/testdata/array/function_param.carbon @@ -8,7 +8,7 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/array/function_param.carbon -fn F(arr: [i32; 3], i: i32) -> i32 { +fn F(arr: array(i32, 3), i: i32) -> i32 { return arr[i]; } diff --git a/toolchain/lower/testdata/basics/numeric_literals.carbon b/toolchain/lower/testdata/basics/numeric_literals.carbon index 296723d62a8e..a2640bb3e10b 100644 --- a/toolchain/lower/testdata/basics/numeric_literals.carbon +++ b/toolchain/lower/testdata/basics/numeric_literals.carbon @@ -11,13 +11,13 @@ fn F() { // 8 and 9 trigger special behavior in APInt when mishandling signed versus // unsigned, so we pay extra attention to those. - var ints: [i32; 4] = ( + var ints: array(i32, 4) = ( 8, 9, 0x8, 0b1000, ); - var floats: [f64; 6] = ( + var floats: array(f64, 6) = ( 0.9, 8.0, 80.0, @@ -78,7 +78,7 @@ fn F() { // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 24, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 20, column: 26, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 29, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 20, column: 31, scope: !4) // CHECK:STDOUT: !10 = !DILocation(line: 20, column: 3, scope: !4) // CHECK:STDOUT: !11 = !DILocation(line: 11, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/index/array_element_access.carbon b/toolchain/lower/testdata/index/array_element_access.carbon index 37505d82c18d..bbd285924a81 100644 --- a/toolchain/lower/testdata/index/array_element_access.carbon +++ b/toolchain/lower/testdata/index/array_element_access.carbon @@ -9,10 +9,10 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/index/array_element_access.carbon fn A() -> (i32, i32) { return (1, 2); } -fn B() -> [i32; 2] { return (1, 2); } +fn B() -> array(i32, 2) { return (1, 2); } fn Run() { - var a: [i32; 2] = A(); + var a: array(i32, 2) = A(); var b: i32 = 1; var c: i32 = a[b]; var d: i32 = B()[1]; @@ -22,7 +22,7 @@ fn Run() { // CHECK:STDOUT: source_filename = "array_element_access.carbon" // CHECK:STDOUT: // CHECK:STDOUT: @tuple.loc10_37 = internal constant { i32, i32 } { i32 1, i32 2 } -// CHECK:STDOUT: @array.loc12_35 = internal constant [2 x i32] [i32 1, i32 2] +// CHECK:STDOUT: @array.loc12_40 = internal constant [2 x i32] [i32 1, i32 2] // CHECK:STDOUT: // CHECK:STDOUT: define void @_CA.Main(ptr sret({ i32, i32 }) %return) !dbg !4 { // CHECK:STDOUT: entry: @@ -34,9 +34,9 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: define void @_CB.Main(ptr sret([2 x i32]) %return) !dbg !9 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %.loc12_34.3.array.index = getelementptr inbounds [2 x i32], ptr %return, i32 0, i64 0, !dbg !10 -// CHECK:STDOUT: %.loc12_34.6.array.index = getelementptr inbounds [2 x i32], ptr %return, i32 0, i64 1, !dbg !10 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @array.loc12_35, i64 8, i1 false), !dbg !11 +// CHECK:STDOUT: %.loc12_39.3.array.index = getelementptr inbounds [2 x i32], ptr %return, i32 0, i64 0, !dbg !10 +// CHECK:STDOUT: %.loc12_39.6.array.index = getelementptr inbounds [2 x i32], ptr %return, i32 0, i64 1, !dbg !10 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @array.loc12_40, i64 8, i1 false), !dbg !11 // CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -47,16 +47,16 @@ fn Run() { // CHECK:STDOUT: %c.var = alloca i32, align 4, !dbg !13 // CHECK:STDOUT: %d.var = alloca i32, align 4, !dbg !13 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %a.var), !dbg !13 -// CHECK:STDOUT: %.loc15_23.1.temp = alloca { i32, i32 }, align 8, !dbg !14 -// CHECK:STDOUT: call void @_CA.Main(ptr %.loc15_23.1.temp), !dbg !14 -// CHECK:STDOUT: %tuple.elem0.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_23.1.temp, i32 0, i32 0, !dbg !14 -// CHECK:STDOUT: %.loc15_23.3 = load i32, ptr %tuple.elem0.tuple.elem, align 4, !dbg !14 -// CHECK:STDOUT: %.loc15_23.4.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i64 0, !dbg !14 -// CHECK:STDOUT: store i32 %.loc15_23.3, ptr %.loc15_23.4.array.index, align 4, !dbg !14 -// CHECK:STDOUT: %tuple.elem1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_23.1.temp, i32 0, i32 1, !dbg !14 -// CHECK:STDOUT: %.loc15_23.6 = load i32, ptr %tuple.elem1.tuple.elem, align 4, !dbg !14 -// CHECK:STDOUT: %.loc15_23.7.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i64 1, !dbg !14 -// CHECK:STDOUT: store i32 %.loc15_23.6, ptr %.loc15_23.7.array.index, align 4, !dbg !14 +// CHECK:STDOUT: %.loc15_28.1.temp = alloca { i32, i32 }, align 8, !dbg !14 +// CHECK:STDOUT: call void @_CA.Main(ptr %.loc15_28.1.temp), !dbg !14 +// CHECK:STDOUT: %tuple.elem0.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_28.1.temp, i32 0, i32 0, !dbg !14 +// CHECK:STDOUT: %.loc15_28.3 = load i32, ptr %tuple.elem0.tuple.elem, align 4, !dbg !14 +// CHECK:STDOUT: %.loc15_28.4.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i64 0, !dbg !14 +// CHECK:STDOUT: store i32 %.loc15_28.3, ptr %.loc15_28.4.array.index, align 4, !dbg !14 +// CHECK:STDOUT: %tuple.elem1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_28.1.temp, i32 0, i32 1, !dbg !14 +// CHECK:STDOUT: %.loc15_28.6 = load i32, ptr %tuple.elem1.tuple.elem, align 4, !dbg !14 +// CHECK:STDOUT: %.loc15_28.7.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i64 1, !dbg !14 +// CHECK:STDOUT: store i32 %.loc15_28.6, ptr %.loc15_28.7.array.index, align 4, !dbg !14 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %b.var), !dbg !13 // CHECK:STDOUT: store i32 1, ptr %b.var, align 4, !dbg !15 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %c.var), !dbg !13 @@ -100,11 +100,11 @@ fn Run() { // CHECK:STDOUT: !7 = !DILocation(line: 10, column: 31, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 10, column: 24, scope: !4) // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "B", linkageName: "_CB.Main", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !10 = !DILocation(line: 12, column: 29, scope: !9) -// CHECK:STDOUT: !11 = !DILocation(line: 12, column: 22, scope: !9) +// CHECK:STDOUT: !10 = !DILocation(line: 12, column: 34, scope: !9) +// CHECK:STDOUT: !11 = !DILocation(line: 12, column: 27, scope: !9) // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !13 = !DILocation(line: 15, column: 3, scope: !12) -// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 21, scope: !12) +// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 26, scope: !12) // CHECK:STDOUT: !15 = !DILocation(line: 16, column: 3, scope: !12) // CHECK:STDOUT: !16 = !DILocation(line: 17, column: 18, scope: !12) // CHECK:STDOUT: !17 = !DILocation(line: 17, column: 16, scope: !12) diff --git a/toolchain/parse/handle_array_expr.cpp b/toolchain/parse/handle_array_expr.cpp index 4bcfbc4fb4f5..041e65c45504 100644 --- a/toolchain/parse/handle_array_expr.cpp +++ b/toolchain/parse/handle_array_expr.cpp @@ -13,28 +13,30 @@ namespace Carbon::Parse { auto HandleArrayExpr(Context& context) -> void { auto state = context.PopState(); - context.AddLeafNode(NodeKind::ArrayExprStart, - context.ConsumeChecked(Lex::TokenKind::OpenSquareBracket), - state.has_error); - context.PushState(state, State::ArrayExprSemi); + auto array_token = context.ConsumeChecked(Lex::TokenKind::Array); + context.AddLeafNode(NodeKind::ArrayExprKeyword, array_token, state.has_error); + if (auto open_paren = context.ConsumeAndAddOpenParen( + array_token, NodeKind::ArrayExprOpenParen)) { + state.token = *open_paren; + } else { + state.has_error = true; + } + context.PushState(state, State::ArrayExprComma); context.PushState(State::Expr); } -auto HandleArrayExprSemi(Context& context) -> void { +auto HandleArrayExprComma(Context& context) -> void { auto state = context.PopState(); - auto semi = context.ConsumeIf(Lex::TokenKind::Semi); - if (!semi) { - context.AddNode(NodeKind::ArrayExprSemi, *context.position(), true); - CARBON_DIAGNOSTIC(ExpectedArraySemi, Error, "expected `;` in array type"); - context.emitter().Emit(*context.position(), ExpectedArraySemi); + if (!context.ConsumeAndAddLeafNodeIf(Lex::TokenKind::Comma, + NodeKind::ArrayExprComma)) { + context.AddLeafNode(NodeKind::ArrayExprComma, *context.position(), true); + CARBON_DIAGNOSTIC(ExpectedArrayComma, Error, + "expected `,` in `array(Type, Count)`"); + context.emitter().Emit(*context.position(), ExpectedArrayComma); state.has_error = true; - } else { - context.AddNode(NodeKind::ArrayExprSemi, *semi, state.has_error); } context.PushState(state, State::ArrayExprFinish); - if (!context.PositionIs(Lex::TokenKind::CloseSquareBracket)) { - context.PushState(State::Expr); - } + context.PushState(State::Expr); } auto HandleArrayExprFinish(Context& context) -> void { diff --git a/toolchain/parse/handle_expr.cpp b/toolchain/parse/handle_expr.cpp index ef981a037210..d62ffe6e45c4 100644 --- a/toolchain/parse/handle_expr.cpp +++ b/toolchain/parse/handle_expr.cpp @@ -149,7 +149,7 @@ auto HandleExprInPostfix(Context& context) -> void { context.PushState(State::ParenExpr); break; } - case Lex::TokenKind::OpenSquareBracket: { + case Lex::TokenKind::Array: { context.PushState(state); context.PushState(State::ArrayExpr); break; diff --git a/toolchain/parse/node_kind.def b/toolchain/parse/node_kind.def index 64bd576eff4b..1ff2fc68d40c 100644 --- a/toolchain/parse/node_kind.def +++ b/toolchain/parse/node_kind.def @@ -157,8 +157,9 @@ CARBON_PARSE_NODE_KIND(ExplicitParamList) CARBON_PARSE_NODE_KIND(ImplicitParamListStart) CARBON_PARSE_NODE_KIND(ImplicitParamList) -CARBON_PARSE_NODE_KIND(ArrayExprStart) -CARBON_PARSE_NODE_KIND(ArrayExprSemi) +CARBON_PARSE_NODE_KIND(ArrayExprOpenParen) +CARBON_PARSE_NODE_KIND(ArrayExprKeyword) +CARBON_PARSE_NODE_KIND(ArrayExprComma) CARBON_PARSE_NODE_KIND(ArrayExpr) CARBON_PARSE_NODE_KIND(LetBindingPattern) diff --git a/toolchain/parse/state.def b/toolchain/parse/state.def index 63aa7b328f9e..29e0f2f845ca 100644 --- a/toolchain/parse/state.def +++ b/toolchain/parse/state.def @@ -73,32 +73,26 @@ CARBON_PARSE_STATE(IndexExpr) // (state done) CARBON_PARSE_STATE(IndexExprFinish) -// Handles an array expression. +// Handles the array keyword and opening paren in an array expression. // -// [T; N] -// ^ +// array(T, N) +// ^~~~~~ // 1. Expr -// 2. ArrayExprSemi +// 2. ArrayExprComma CARBON_PARSE_STATE(ArrayExpr) -// Handles ';' in an array expression. +// Handles ',' in an array expression. // -// [T;] -// ^ -// 1. ArrayExprFinish -// -// [T; N] -// ^ +// array(T, N) +// ^ // 1. Expr // 2. ArrayExprFinish -CARBON_PARSE_STATE(ArrayExprSemi) +CARBON_PARSE_STATE(ArrayExprComma) // Handles finishing the array expression. // -// [T;] -// ^ -// [T; N] -// ^ +// array(T, N) +// ^ // (state done) CARBON_PARSE_STATE(ArrayExprFinish) diff --git a/toolchain/parse/testdata/array/with_length.carbon b/toolchain/parse/testdata/array/basic.carbon similarity index 62% rename from toolchain/parse/testdata/array/with_length.carbon rename to toolchain/parse/testdata/array/basic.carbon index 0b78f611a603..7651bf446ee5 100644 --- a/toolchain/parse/testdata/array/with_length.carbon +++ b/toolchain/parse/testdata/array/basic.carbon @@ -4,24 +4,25 @@ // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/array/with_length.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/array/basic.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/array/with_length.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/array/basic.carbon -var x: [i32; 10]; +var x: array(i32, 10); -// CHECK:STDOUT: - filename: with_length.carbon +// CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ','}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '10'}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/array/fail_require_close_bracket.carbon b/toolchain/parse/testdata/array/fail_require_close_bracket.carbon deleted file mode 100644 index f72681777da5..000000000000 --- a/toolchain/parse/testdata/array/fail_require_close_bracket.carbon +++ /dev/null @@ -1,29 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/array/fail_require_close_bracket.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/array/fail_require_close_bracket.carbon -// TODO: It should emit only one error message. - -// CHECK:STDERR: fail_require_close_bracket.carbon:[[@LINE+4]]:8: error: opening symbol without a corresponding closing symbol [UnmatchedOpening] -// CHECK:STDERR: var x: [i32;; -// CHECK:STDERR: ^ -// CHECK:STDERR: -var x: [i32;; - -// CHECK:STDOUT: - filename: fail_require_close_bracket.carbon -// CHECK:STDOUT: parse_tree: [ -// CHECK:STDOUT: {kind: 'FileStart', text: ''}, -// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'EmptyDecl', text: ';'}, -// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, -// CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/array/fail_require_semi.carbon b/toolchain/parse/testdata/array/fail_require_semi.carbon deleted file mode 100644 index 21ffd34eed3a..000000000000 --- a/toolchain/parse/testdata/array/fail_require_semi.carbon +++ /dev/null @@ -1,30 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/array/fail_require_semi.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/array/fail_require_semi.carbon - -// CHECK:STDERR: fail_require_semi.carbon:[[@LINE+4]]:12: error: expected `;` in array type [ExpectedArraySemi] -// CHECK:STDERR: var x: [i32]; -// CHECK:STDERR: ^ -// CHECK:STDERR: -var x: [i32]; - -// CHECK:STDOUT: - filename: fail_require_semi.carbon -// CHECK:STDOUT: parse_tree: [ -// CHECK:STDOUT: {kind: 'FileStart', text: ''}, -// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, -// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, -// CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/array/fail_syntax.carbon b/toolchain/parse/testdata/array/fail_syntax.carbon index 3f52af452d3d..b3c877141733 100644 --- a/toolchain/parse/testdata/array/fail_syntax.carbon +++ b/toolchain/parse/testdata/array/fail_syntax.carbon @@ -8,78 +8,140 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/array/fail_syntax.carbon -// --- fail_type.carbon +// --- fail_no_comma.carbon -// CHECK:STDERR: fail_type.carbon:[[@LINE+4]]:12: error: expected `;` in array type [ExpectedArraySemi] -// CHECK:STDERR: var x: [i32]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_no_comma.carbon:[[@LINE+8]]:17: error: expected `,` in `array(Type, Count)` [ExpectedArrayComma] +// CHECK:STDERR: var x: array(i32); +// CHECK:STDERR: ^ // CHECK:STDERR: -var x: [i32]; +// CHECK:STDERR: fail_no_comma.carbon:[[@LINE+4]]:17: error: expected expression [ExpectedExpr] +// CHECK:STDERR: var x: array(i32); +// CHECK:STDERR: ^ +// CHECK:STDERR: +var x: array(i32); // --- fail_invalid_char.carbon -// CHECK:STDERR: fail_invalid_char.carbon:[[@LINE+16]]:12: error: expected expression [ExpectedExpr] -// CHECK:STDERR: fn X() -> [:]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_invalid_char.carbon:[[@LINE+16]]:17: error: expected expression [ExpectedExpr] +// CHECK:STDERR: fn X() -> array(:); +// CHECK:STDERR: ^ // CHECK:STDERR: -// CHECK:STDERR: fail_invalid_char.carbon:[[@LINE+12]]:12: error: expected `;` in array type [ExpectedArraySemi] -// CHECK:STDERR: fn X() -> [:]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_invalid_char.carbon:[[@LINE+12]]:17: error: expected `,` in `array(Type, Count)` [ExpectedArrayComma] +// CHECK:STDERR: fn X() -> array(:); +// CHECK:STDERR: ^ // CHECK:STDERR: -// CHECK:STDERR: fail_invalid_char.carbon:[[@LINE+8]]:12: error: expected expression [ExpectedExpr] -// CHECK:STDERR: fn X() -> [:]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_invalid_char.carbon:[[@LINE+8]]:17: error: expected expression [ExpectedExpr] +// CHECK:STDERR: fn X() -> array(:); +// CHECK:STDERR: ^ // CHECK:STDERR: -// CHECK:STDERR: fail_invalid_char.carbon:[[@LINE+4]]:12: error: unexpected tokens before `]` [ExpectedCloseSymbol] -// CHECK:STDERR: fn X() -> [:]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_invalid_char.carbon:[[@LINE+4]]:17: error: unexpected tokens before `)` [ExpectedCloseSymbol] +// CHECK:STDERR: fn X() -> array(:); +// CHECK:STDERR: ^ // CHECK:STDERR: -fn X() -> [:]; +fn X() -> array(:); // --- fail_unlexed_expr.carbon -// CHECK:STDERR: fail_unlexed_expr.carbon:[[@LINE+12]]:9: error: encountered unrecognized characters while parsing [UnrecognizedCharacters] -// CHECK:STDERR: var y: [`]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_unlexed_expr.carbon:[[@LINE+12]]:14: error: encountered unrecognized characters while parsing [UnrecognizedCharacters] +// CHECK:STDERR: var y: array(`); +// CHECK:STDERR: ^ // CHECK:STDERR: -// CHECK:STDERR: fail_unlexed_expr.carbon:[[@LINE+8]]:9: error: expected `;` in array type [ExpectedArraySemi] -// CHECK:STDERR: var y: [`]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_unlexed_expr.carbon:[[@LINE+8]]:14: error: expected `,` in `array(Type, Count)` [ExpectedArrayComma] +// CHECK:STDERR: var y: array(`); +// CHECK:STDERR: ^ // CHECK:STDERR: -// CHECK:STDERR: fail_unlexed_expr.carbon:[[@LINE+4]]:9: error: unexpected tokens before `]` [ExpectedCloseSymbol] -// CHECK:STDERR: var y: [`]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_unlexed_expr.carbon:[[@LINE+4]]:14: error: unexpected tokens before `)` [ExpectedCloseSymbol] +// CHECK:STDERR: var y: array(`); +// CHECK:STDERR: ^ // CHECK:STDERR: -var y: [`]; +var y: array(`); -// --- fail_no_close_bracket.carbon +// --- fail_no_open_paren.carbon -// CHECK:STDERR: fail_no_close_bracket.carbon:[[@LINE+4]]:8: error: opening symbol without a corresponding closing symbol [UnmatchedOpening] -// CHECK:STDERR: var x: [i32;; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_no_open_paren.carbon:[[@LINE+4]]:14: error: expected `(` after `array` [ExpectedParenAfter] +// CHECK:STDERR: var x: array i32, 1; +// CHECK:STDERR: ^~~ // CHECK:STDERR: -var x: [i32;; +var x: array i32, 1; -// --- fail_no_semi.carbon +// --- fail_no_close_paren.carbon -// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+4]]:12: error: expected `;` in array type [ExpectedArraySemi] -// CHECK:STDERR: var x: [i32]; -// CHECK:STDERR: ^ +// CHECK:STDERR: fail_no_close_paren.carbon:[[@LINE+16]]:13: error: opening symbol without a corresponding closing symbol [UnmatchedOpening] +// CHECK:STDERR: var x: array(i32,; +// CHECK:STDERR: ^ // CHECK:STDERR: -var x: [i32]; +// CHECK:STDERR: fail_no_close_paren.carbon:[[@LINE+12]]:13: error: expected `(` after `array` [ExpectedParenAfter] +// CHECK:STDERR: var x: array(i32,; +// CHECK:STDERR: ^ +// CHECK:STDERR: +// CHECK:STDERR: fail_no_close_paren.carbon:[[@LINE+8]]:13: error: expected `,` in `array(Type, Count)` [ExpectedArrayComma] +// CHECK:STDERR: var x: array(i32,; +// CHECK:STDERR: ^ +// CHECK:STDERR: +// CHECK:STDERR: fail_no_close_paren.carbon:[[@LINE+4]]:13: error: `var` declarations must end with a `;` [ExpectedDeclSemi] +// CHECK:STDERR: var x: array(i32,; +// CHECK:STDERR: ^ +// CHECK:STDERR: +var x: array(i32,; -// CHECK:STDOUT: - filename: fail_type.carbon +// --- fail_no_length.carbon + +// CHECK:STDERR: fail_no_length.carbon:[[@LINE+4]]:18: error: expected expression [ExpectedExpr] +// CHECK:STDERR: var x: array(i32,); +// CHECK:STDERR: ^ +// CHECK:STDERR: +var x: array(i32,); + +// --- fail_no_params.carbon + +// CHECK:STDERR: fail_no_params.carbon:[[@LINE+12]]:14: error: expected expression [ExpectedExpr] +// CHECK:STDERR: var x: array(); +// CHECK:STDERR: ^ +// CHECK:STDERR: +// CHECK:STDERR: fail_no_params.carbon:[[@LINE+8]]:14: error: expected `,` in `array(Type, Count)` [ExpectedArrayComma] +// CHECK:STDERR: var x: array(); +// CHECK:STDERR: ^ +// CHECK:STDERR: +// CHECK:STDERR: fail_no_params.carbon:[[@LINE+4]]:14: error: expected expression [ExpectedExpr] +// CHECK:STDERR: var x: array(); +// CHECK:STDERR: ^ +// CHECK:STDERR: +var x: array(); + +// --- fail_keyword_alone.carbon + +// CHECK:STDERR: fail_keyword_alone.carbon:[[@LINE+16]]:13: error: expected `(` after `array` [ExpectedParenAfter] +// CHECK:STDERR: var x: array; +// CHECK:STDERR: ^ +// CHECK:STDERR: +// CHECK:STDERR: fail_keyword_alone.carbon:[[@LINE+12]]:13: error: expected expression [ExpectedExpr] +// CHECK:STDERR: var x: array; +// CHECK:STDERR: ^ +// CHECK:STDERR: +// CHECK:STDERR: fail_keyword_alone.carbon:[[@LINE+8]]:13: error: expected `,` in `array(Type, Count)` [ExpectedArrayComma] +// CHECK:STDERR: var x: array; +// CHECK:STDERR: ^ +// CHECK:STDERR: +// CHECK:STDERR: fail_keyword_alone.carbon:[[@LINE+4]]:13: error: expected expression [ExpectedExpr] +// CHECK:STDERR: var x: array; +// CHECK:STDERR: ^ +// CHECK:STDERR: +var x: array; + +// CHECK:STDOUT: - filename: fail_no_comma.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ')', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] // CHECK:STDOUT: - filename: fail_invalid_char.carbon @@ -89,13 +151,14 @@ var x: [i32]; // CHECK:STDOUT: {kind: 'IdentifierNameBeforeParams', text: 'X'}, // CHECK:STDOUT: {kind: 'ExplicitParamListStart', text: '('}, // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ':', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ':', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ':', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 5}, -// CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ':', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ':', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 12}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] // CHECK:STDOUT: - filename: fail_unlexed_expr.carbon @@ -103,39 +166,94 @@ var x: [i32]; // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '`', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: '`', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '`', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: '`', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '`', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDOUT: - filename: fail_no_close_bracket.carbon +// CHECK:STDOUT: - filename: fail_no_open_paren.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'EmptyDecl', text: ';'}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: 'array', has_error: yes}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ','}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: 'array', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDOUT: - filename: fail_no_semi.carbon +// CHECK:STDOUT: - filename: fail_no_close_paren.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: 'array', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '(', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: '(', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '(', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: 'array', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', has_error: yes, subtree_size: 11}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: - filename: fail_no_length.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ','}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: - filename: fail_no_params.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ')', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: - filename: fail_keyword_alone.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: 'array', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ';', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: 'array', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/array/without_length.carbon b/toolchain/parse/testdata/array/without_length.carbon deleted file mode 100644 index 81867a3f0094..000000000000 --- a/toolchain/parse/testdata/array/without_length.carbon +++ /dev/null @@ -1,26 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/array/without_length.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/array/without_length.carbon - -var x: [i32;]; - -// CHECK:STDOUT: - filename: without_length.carbon -// CHECK:STDOUT: parse_tree: [ -// CHECK:STDOUT: {kind: 'FileStart', text: ''}, -// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, -// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, -// CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/fail_bracket_recovery.carbon b/toolchain/parse/testdata/basics/fail_bracket_recovery.carbon index 39575327a859..4085c1b6dd98 100644 --- a/toolchain/parse/testdata/basics/fail_bracket_recovery.carbon +++ b/toolchain/parse/testdata/basics/fail_bracket_recovery.carbon @@ -10,11 +10,12 @@ // This is a valid parse tree even though the lex errors. fn F() { - // CHECK:STDERR: fail_bracket_recovery.carbon:[[@LINE+4]]:11: error: opening symbol without a corresponding closing symbol [UnmatchedOpening] - // CHECK:STDERR: var x: ([i32; 3) = (0, 1, 2); - // CHECK:STDERR: ^ + var a: array(i32, 3) = (0, 1, 2); + // CHECK:STDERR: fail_bracket_recovery.carbon:[[@LINE+4]]:5: error: opening symbol without a corresponding closing symbol [UnmatchedOpening] + // CHECK:STDERR: (a[1) + 1; + // CHECK:STDERR: ^ // CHECK:STDERR: - var x: ([i32; 3) = (0, 1, 2); + (a[1) + 1; // CHECK:STDERR: fail_bracket_recovery.carbon:[[@LINE+12]]:15: error: opening symbol without a corresponding closing symbol [UnmatchedOpening] // CHECK:STDERR: var x: {.y: (} = {.y = ((}; // CHECK:STDERR: ^ @@ -39,16 +40,15 @@ fn F() { // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ParenExprStart', text: '('}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 9}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ','}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, @@ -57,7 +57,16 @@ fn F() { // CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '2'}, // CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 20}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 19}, +// CHECK:STDOUT: {kind: 'ParenExprStart', text: '('}, +// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'}, +// CHECK:STDOUT: {kind: 'IndexExprStart', text: '[', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, +// CHECK:STDOUT: {kind: 'IndexExpr', text: ']', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, +// CHECK:STDOUT: {kind: 'InfixOperatorPlus', text: '+', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, // CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, @@ -80,6 +89,6 @@ fn F() { // CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 7}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 22}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 48}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 56}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/numeric_literals.carbon b/toolchain/parse/testdata/basics/numeric_literals.carbon index 227768fb3f14..1441b5e391fa 100644 --- a/toolchain/parse/testdata/basics/numeric_literals.carbon +++ b/toolchain/parse/testdata/basics/numeric_literals.carbon @@ -11,14 +11,14 @@ fn F() { // 8 and 9 trigger special behavior in APInt when mishandling signed versus // unsigned, so we pay extra attention to those. - var ints: [i32; 5] = ( + var ints: array(i32, 5) = ( 8, 9, 0x8, 0b1000, 39999999999999999993, ); - var floats: [f64; 7] = ( + var floats: array(f64, 7) = ( 0.9, 8.0, 80.0, @@ -39,13 +39,14 @@ fn F() { // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'ints'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ','}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '5'}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '8'}, @@ -59,16 +60,17 @@ fn F() { // CHECK:STDOUT: {kind: 'IntLiteral', text: '39999999999999999993'}, // CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 12}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 23}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 24}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'floats'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'FloatTypeLiteral', text: 'f64'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExprKeyword', text: 'array'}, +// CHECK:STDOUT: {kind: 'ArrayExprOpenParen', text: '('}, +// CHECK:STDOUT: {kind: 'FloatTypeLiteral', text: 'f64'}, +// CHECK:STDOUT: {kind: 'ArrayExprComma', text: ','}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '7'}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ')', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, // CHECK:STDOUT: {kind: 'RealLiteral', text: '0.9'}, @@ -86,7 +88,7 @@ fn F() { // CHECK:STDOUT: {kind: 'RealLiteral', text: '39999999999999999993.0e39999999999999999993'}, // CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 16}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 27}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 56}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 28}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 58}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/for/fail_square_brackets.carbon b/toolchain/parse/testdata/for/fail_square_brackets.carbon index 22100f2daf2d..656c6f7cba89 100644 --- a/toolchain/parse/testdata/for/fail_square_brackets.carbon +++ b/toolchain/parse/testdata/for/fail_square_brackets.carbon @@ -9,21 +9,25 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/for/fail_square_brackets.carbon fn F() { - // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+16]]:7: error: expected `(` after `for` [ExpectedParenAfter] + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+20]]:7: error: expected `(` after `for` [ExpectedParenAfter] // CHECK:STDERR: for [] { // CHECK:STDERR: ^ // CHECK:STDERR: - // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+12]]:7: error: expected `var` declaration [ExpectedVariableDecl] + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+16]]:7: error: expected `var` declaration [ExpectedVariableDecl] // CHECK:STDERR: for [] { // CHECK:STDERR: ^ // CHECK:STDERR: - // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+8]]:8: error: expected expression [ExpectedExpr] + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+12]]:7: error: expected expression [ExpectedExpr] // CHECK:STDERR: for [] { - // CHECK:STDERR: ^ + // CHECK:STDERR: ^ // CHECK:STDERR: - // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+4]]:8: error: expected `;` in array type [ExpectedArraySemi] + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+8]]:7: error: expected braced code block [ExpectedCodeBlock] // CHECK:STDERR: for [] { - // CHECK:STDERR: ^ + // CHECK:STDERR: ^ + // CHECK:STDERR: + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+4]]:7: error: expected expression [ExpectedExpr] + // CHECK:STDERR: for [] { + // CHECK:STDERR: ^ // CHECK:STDERR: for [] { } @@ -38,14 +42,13 @@ fn F() { // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'ForHeaderStart', text: 'for', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ']', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'ForHeader', text: 'for', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'}, -// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 9}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 15}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, +// CHECK:STDOUT: {kind: 'ForHeader', text: 'for', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '[', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, +// CHECK:STDOUT: {kind: 'ExprStatement', text: '}', has_error: yes, subtree_size: 2}, +// CHECK:STDOUT: {kind: 'CodeBlock', text: '[', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 14}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/if/fail_square_brackets.carbon b/toolchain/parse/testdata/if/fail_square_brackets.carbon index f509718de253..65a92835d008 100644 --- a/toolchain/parse/testdata/if/fail_square_brackets.carbon +++ b/toolchain/parse/testdata/if/fail_square_brackets.carbon @@ -9,17 +9,21 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if/fail_square_brackets.carbon fn F() { - // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+12]]:6: error: expected `(` after `if` [ExpectedParenAfter] + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+16]]:6: error: expected `(` after `if` [ExpectedParenAfter] // CHECK:STDERR: if [] {} // CHECK:STDERR: ^ // CHECK:STDERR: - // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+8]]:7: error: expected expression [ExpectedExpr] + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+12]]:6: error: expected expression [ExpectedExpr] // CHECK:STDERR: if [] {} - // CHECK:STDERR: ^ + // CHECK:STDERR: ^ // CHECK:STDERR: - // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+4]]:7: error: expected `;` in array type [ExpectedArraySemi] + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+8]]:6: error: expected braced code block [ExpectedCodeBlock] // CHECK:STDERR: if [] {} - // CHECK:STDERR: ^ + // CHECK:STDERR: ^ + // CHECK:STDERR: + // CHECK:STDERR: fail_square_brackets.carbon:[[@LINE+4]]:6: error: expected expression [ExpectedExpr] + // CHECK:STDERR: if [] {} + // CHECK:STDERR: ^ // CHECK:STDERR: if [] {} } @@ -33,14 +37,13 @@ fn F() { // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'IfConditionStart', text: 'if', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ']', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'}, -// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 9}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 15}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, +// CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '[', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, +// CHECK:STDOUT: {kind: 'ExprStatement', text: '}', has_error: yes, subtree_size: 2}, +// CHECK:STDOUT: {kind: 'CodeBlock', text: '[', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 14}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/typed_nodes.h b/toolchain/parse/typed_nodes.h index 7d244fed3128..915ffc395c73 100644 --- a/toolchain/parse/typed_nodes.h +++ b/toolchain/parse/typed_nodes.h @@ -805,29 +805,25 @@ struct MatchStatement { // Expression nodes // ---------------- -using ArrayExprStart = - LeafNode; +using ArrayExprKeyword = + LeafNode; -// The start of an array type, `[i32;`. -// -// TODO: Consider flattening this into `ArrayExpr`. -struct ArrayExprSemi { - static constexpr auto Kind = NodeKind::ArrayExprSemi.Define( - {.bracketed_by = ArrayExprStart::Kind, .child_count = 2}); +using ArrayExprOpenParen = + LeafNode; - ArrayExprStartId left_square; - AnyExprId type; - Lex::SemiTokenIndex token; -}; +using ArrayExprComma = LeafNode; -// An array type, such as `[i32; 3]` or `[i32;]`. +// An array type, `array(T, N)`. struct ArrayExpr { static constexpr auto Kind = NodeKind::ArrayExpr.Define( - {.category = NodeCategory::Expr, .bracketed_by = ArrayExprSemi::Kind}); + {.category = NodeCategory::Expr, .child_count = 5}); - ArrayExprSemiId start; - std::optional bound; - Lex::CloseSquareBracketTokenIndex token; + ArrayExprKeywordId keyword; + ArrayExprOpenParenId start; + AnyExprId type; + ArrayExprCommaId comma; + AnyExprId bound; + Lex::CloseParenTokenIndex token; }; // The opening portion of an indexing expression: `a[`. diff --git a/toolchain/parse/typed_nodes_test.cpp b/toolchain/parse/typed_nodes_test.cpp index 6d0c9567129d..06a9401b336d 100644 --- a/toolchain/parse/typed_nodes_test.cpp +++ b/toolchain/parse/typed_nodes_test.cpp @@ -110,7 +110,7 @@ TEST_F(TypedNodeTest, ModifierOrder) { TEST_F(TypedNodeTest, For) { auto& tree = compile_helper_.GetTreeAndSubtrees(R"carbon( - fn F(arr: [i32; 5]) { + fn F(arr: array(i32, 5)) { for (var v: i32 in arr) { Print(v); }