mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Added "weak" type aliases def Foo = my_foo::Foo @weak;
This commit is contained in:
32
test/test_suite/define/weak_alias_fails.c3
Normal file
32
test/test_suite/define/weak_alias_fails.c3
Normal file
@@ -0,0 +1,32 @@
|
||||
module abc;
|
||||
import std::math;
|
||||
def Vec2f = std::math::vector::Vec2f @weak;
|
||||
fn Vec2f foo(Vec2f a) { return a * 2; }
|
||||
|
||||
module gog;
|
||||
import std::math;
|
||||
def Vec2f = std::math::vector::Vec2f;
|
||||
|
||||
module deef;
|
||||
import gog;
|
||||
|
||||
def Vec2f = gog::Vec2f @weak;
|
||||
fn Vec2f foo(Vec2f a) { return a * 2; }
|
||||
|
||||
module test;
|
||||
import abc;
|
||||
import std::math;
|
||||
fn void test()
|
||||
{
|
||||
Vec2f a;
|
||||
abc::foo(a);
|
||||
}
|
||||
|
||||
module test2;
|
||||
import abc;
|
||||
import deef;
|
||||
fn void test2()
|
||||
{
|
||||
Vec2f a; // #error: abc::Vec2f or deef::Vec2f
|
||||
abc::foo(a);
|
||||
}
|
||||
32
test/test_suite/define/weak_aliases.c3
Normal file
32
test/test_suite/define/weak_aliases.c3
Normal file
@@ -0,0 +1,32 @@
|
||||
module abc;
|
||||
import std::math;
|
||||
def Vec2f = std::math::vector::Vec2f @weak;
|
||||
fn Vec2f foo(Vec2f a) { return a * 2; }
|
||||
|
||||
module gog;
|
||||
import std::math;
|
||||
def Vec2f = std::math::vector::Vec2f @weak;
|
||||
|
||||
module deef;
|
||||
import gog;
|
||||
|
||||
def Vec2f = gog::Vec2f @weak;
|
||||
fn Vec2f foo(Vec2f a) { return a * 2; }
|
||||
|
||||
module test;
|
||||
import abc;
|
||||
import std::math;
|
||||
fn void test()
|
||||
{
|
||||
Vec2f a;
|
||||
abc::foo(a);
|
||||
}
|
||||
|
||||
module test2;
|
||||
import abc;
|
||||
import deef;
|
||||
fn void test2()
|
||||
{
|
||||
Vec2f a;
|
||||
abc::foo(a);
|
||||
}
|
||||
@@ -23,5 +23,5 @@ fn void test2()
|
||||
c = foo::b;
|
||||
c = bar::b;
|
||||
c = foo::a;
|
||||
c = b; // #error: global variable needs a path prefix (e.g. 'bar::b')
|
||||
c = b; // #error: global variable needs a path prefix (e.g. 'foo::b')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user