mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Deprecating multi-level array length inference. int[*][*] is deprecated and will be removed 0.8.0.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import std;
|
||||
macro void test(int[*][6] a)
|
||||
macro void test(int[2][6] a)
|
||||
{
|
||||
}
|
||||
fn void main()
|
||||
|
||||
@@ -3,8 +3,8 @@ module test;
|
||||
|
||||
fn void main()
|
||||
{
|
||||
int[*][*][2][*]? y = { {{{1}, {2}}, { {3}, {4}}}};
|
||||
int[*][*][2][*] x = { {{{1}, {2}}, { {3}, {4}}}};
|
||||
int[1][2][2][*]? y = { {{{1}, {2}}, { {3}, {4}}}};
|
||||
int[1][2][2][*] x = { {{{1}, {2}}, { {3}, {4}}}};
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
fn void test1()
|
||||
{
|
||||
var $d = { {1}, {2, 3} };
|
||||
var $e = (int[*][*])$d; // #error: contains elements that have different lengths
|
||||
var $e = (int[2][*])$d; // #error: This untyped list contained an element
|
||||
}
|
||||
|
||||
fn void test2()
|
||||
{
|
||||
var $d = { {1}, {3}, {2} };
|
||||
var $e = (int[*][*])$d;
|
||||
var $e = (int[1][*])$d;
|
||||
}
|
||||
|
||||
fn void test3()
|
||||
{
|
||||
var $d = { {1}, {} };
|
||||
var $e = (int[*][*])$d; // #error: This untyped list contained an element of type
|
||||
var $e = (int[1][*])$d;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
module test;
|
||||
char[1][*] a = { [0] = { [0] = 1 } };
|
||||
char[1][1] b = { [0] = { [0] = 1 } };
|
||||
char[*][*] c = { [0] = { [0] = 1 } };
|
||||
char[*][1] d = { [0] = { [0] = 1 } };
|
||||
char[2][*] c = { [0] = { [0] = 1 } };
|
||||
char[4][1] d = { [0] = { [0] = 1 } };
|
||||
|
||||
fn void main()
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import std;
|
||||
macro test(int[*][1] a) {
|
||||
macro test(int[1][1] a) {
|
||||
var b = a;
|
||||
}
|
||||
|
||||
fn int main()
|
||||
{
|
||||
int[][1] b;
|
||||
test(b); // #error: It is not possible to cast 'int[][1]' to 'int[*][1]'
|
||||
test(b); // #error: It is not possible to cast 'int[][1]' to 'int[1][1]'
|
||||
return 12;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
fn void main()
|
||||
{
|
||||
int[*][*][] x = (int[2][1][]) { { { 1, 2 } } };
|
||||
int[*][*][*] y = (int[2][1][]) { { { 1, 2 } } };
|
||||
int[2][1][*] y = (int[2][1][]) { { { 1, 2 } } };
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ import std;
|
||||
fn int main()
|
||||
{
|
||||
char[] a = "hello";
|
||||
char[*] b = *(char[*]*)&a; // #error: cannot be used to infer the length
|
||||
char[*] b = *(char[5]*)a.ptr;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import std;
|
||||
fn void main()
|
||||
{
|
||||
char[*]* x = "abc"; // #error: You cannot cast 'String' to 'char[*]*'
|
||||
io::printn($typeof(x).nameof);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
|
||||
macro int test(int[*][*]* y)
|
||||
macro int test(int[2][2]* y)
|
||||
{
|
||||
$typeof(*y) z = *y;
|
||||
return z[1][1];
|
||||
@@ -11,7 +11,7 @@ fn void main()
|
||||
{
|
||||
int[2][*] x = { { 2, 3}, { 5, 6 }};
|
||||
int[<2>][*] y = { { 1, 3 }};
|
||||
int[<*>][*] z = y;
|
||||
int[<2>][*] z = y;
|
||||
int[<2>][1] w = z;
|
||||
int[<2>][] aa = { { 1, 3 }};
|
||||
int[][*] bb = { { 1, 3 } };
|
||||
|
||||
@@ -27,6 +27,6 @@ struct Baz { int x; }
|
||||
|
||||
fn void test4()
|
||||
{
|
||||
Baz[2][*] x = { { { 2 } , { 3 } }, {{5}, {6} }};
|
||||
Bar[*][*] y = (Bar[2][2])x;
|
||||
Baz[2][2] x = { { { 2 } , { 3 } }, {{5}, {6} }};
|
||||
Bar[2][2] y = (Bar[2][2])x;
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
fn int main()
|
||||
{
|
||||
int [*][] y = { }; // #error: Inferring the slice inner type from an empty initializer is not possible
|
||||
return 0;
|
||||
}
|
||||
@@ -30,6 +30,6 @@ fn void pointer_add_sub_diff()
|
||||
assert(w == { -1, 2 });
|
||||
int*[<2>] zz = y - (y - yy);
|
||||
assert(zz[0] == &a[1] && zz[1] == &a[2]);
|
||||
int[*]*[<2>] g = (int[2]*[<2>]) { null, null };
|
||||
int[*]*[<*>] g2 = (int[2]*[<2>]) { null, null };
|
||||
int[2]*[<2>] g = { null, null };
|
||||
int[2]*[<2>] g2 = { null, null };
|
||||
}
|
||||
Reference in New Issue
Block a user