mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
"poison" the current function early when a declaration can't be correctly resolved.
This commit is contained in:
@@ -442,7 +442,7 @@ fn void test_file(Path file_path)
|
||||
// Start process
|
||||
SubProcess compilation = process::create(cmdline.array_view(), { .search_user_path, .no_window, .inherit_environment })!!;
|
||||
defer compilation.destroy();
|
||||
CInt result = compilation.join()!!;
|
||||
CInt result = compilation.join() ?? 1;
|
||||
DString out;
|
||||
io::copy_to(&&compilation.stderr(), &out)!!;
|
||||
if (result != 0 && result != 1)
|
||||
|
||||
@@ -25,13 +25,15 @@ struct BazTwo
|
||||
fn void test()
|
||||
{
|
||||
Foo x;
|
||||
Bar y = (Bar)(x); // #error: 'Foo' to 'Bar'
|
||||
{ Bar y = (Bar)(x); } // #error: 'Foo' to 'Bar'
|
||||
|
||||
Baz z;
|
||||
int[2] w = (int[2])(z); // #error: 'Baz' to 'int[2]'
|
||||
z = (Baz)(w);
|
||||
BazTwo v = (BazTwo)(z); // #error: 'Baz' to 'BazTwo'
|
||||
v = (BazTwo)(w);
|
||||
z = (Baz)(v);
|
||||
w = (int[2])(v);
|
||||
{ int[2] w = (int[2])(z); } // #error: 'Baz' to 'int[2]'
|
||||
int[2] w;
|
||||
z = (Baz)(w); // #error: to 'Baz'
|
||||
{ BazTwo v = (BazTwo)(z); } // #error: 'Baz' to 'BazTwo'
|
||||
BazTwo v;
|
||||
v = (BazTwo)(w); // #error: to 'BazTwo'
|
||||
z = (Baz)(v); // #error: possible to cast 'BazTwo' to 'Baz'
|
||||
w = (int[2])(v); // #error: possible to cast 'BazTwo' to 'int[2]'
|
||||
}
|
||||
|
||||
@@ -10,6 +10,18 @@ $foreach $c : $chars:
|
||||
int $offset = ($c - $from) / BITS;
|
||||
int $rem = ($c - $from) % BITS;
|
||||
uint128 $value = $bitmap[$offset]; // #error: is out of range
|
||||
$endforeach
|
||||
}
|
||||
|
||||
fn int main2()
|
||||
{
|
||||
String $chars = "Abcd";
|
||||
char $from = 2;
|
||||
char[10] $bitmap = {};
|
||||
$foreach $c : $chars:
|
||||
int $offset = ($c - $from) / BITS;
|
||||
int $rem = ($c - $from) % BITS;
|
||||
uint128 $value = 1;
|
||||
$value |= 1ULL << $rem;
|
||||
$bitmap = $bitmap[:$offset] +++ $value +++ $bitmap[$offset+1..]; // #error: End index out of bounds
|
||||
$endforeach
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
module testing;
|
||||
import std::io;
|
||||
|
||||
macro char[] read(src, Allocator allocator, n)
|
||||
macro void read(src, Allocator allocator, n)
|
||||
{
|
||||
char* data = allocator::malloc_try(allocator, n)!; // #error: Rethrow is only allowed in macros
|
||||
io::read_all(src, data[:n])!;
|
||||
(void)io::read_all(src, data[:n]);
|
||||
}
|
||||
|
||||
fn void main()
|
||||
{
|
||||
ByteReader br;
|
||||
read(&br, allocator::temp(), 10);
|
||||
read(&br, allocator::temp(), 10)!!;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import abc @norecurse @public;
|
||||
|
||||
fn int test()
|
||||
{
|
||||
Abc x; // #error: is '@private'
|
||||
{ Abc x; } // #error: is '@private'
|
||||
abc::baz::test(); // #error: is '@private'
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user