You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Minimal code (you may need to add some imports, because I carved this snippet from another code):
moduletest;
importstd::io;
structMyFoo {
uintidx;
}
structMyFooIter {
MyFoo*parent;
uintidx;
}
macroMyFooIterMyFoo.iter(&self) {
return (MyFooIter){.parent=self};
}
macroMyFoo*!MyFooIter.next(&self) {
MyFoofoo= {.idx=999};
// expected to always failif (!mem::equals(&foo, self.parent, MyFoo.sizeof)) {
returnIoError.GENERAL_ERROR?;
}
returnself.parent;
}
moduletest@test;
fnvoidtest_myfoo()
{
MyFoofoo;
MyFooIteriter=foo.iter();
// This will compile and blow up with GENERAL_ERROR (expected)// iter.next()!!;// This doesn't compile with weird errortest::@error(iter.next(), IoError.GENERAL_ERROR);
}
Error:
416: macro bool equals(a, b, isz len = -1, usz $align = 0)
417: {
418: $if !$align:
419: $align = $typeof(a[0]).alignof;
^^^^^^
(/home/ubertrader/code/c3c/lib/std/core/mem.c3:419:3) Error: Compile time variables may only be modified in the scope they are defined in.
70: macro MyFoo*! MyFooIter.next(&self) {
71: MyFoo foo = {.idx = 999};
72:
73: if (!mem::equals(&foo, self.parent, MyFoo.sizeof)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(/home/ubertrader/code/c3tools/test/c3tools/lsp/test_symhash.c3:73:10) Note: Inlined from here.
88: *>
89: macro @error(#funcresult, anyfault error_expected)
90: {
91: if (catch err = #funcresult) {
^^^^^^^^^^^
(/home/ubertrader/code/c3c/lib/std/core/test.c3:91:18) Note: Inlined from here.
442: $Type = uint;
443: $case 8:
444: $default:
445: $Type = ulong;
^^^^^
(/home/ubertrader/code/c3c/lib/std/core/mem.c3:445:4) Error: Compile time variables may only be modified in the scope they are defined in.
70: macro MyFoo*! MyFooIter.next(&self) {
71: MyFoo foo = {.idx = 999};
72:
73: if (!mem::equals(&foo, self.parent, MyFoo.sizeof)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(/home/ubertrader/code/c3tools/test/c3tools/lsp/test_symhash.c3:73:10) Note: Inlined from here.
88: *>
89: macro @error(#funcresult, anyfault error_expected)
90: {
91: if (catch err = #funcresult) {
^^^^^^^^^^^
(/home/ubertrader/code/c3c/lib/std/core/test.c3:91:18) Note: Inlined from here.
444: $default:
445: $Type = ulong;
446: $endswitch
447: var $step = $Type.sizeof;
^^^^^
(/home/ubertrader/code/c3c/lib/std/core/mem.c3:447:14) Error: You need to assign a type to '$Type' before using it.
This is a problem with detecting that the compile time variable isn't actually modified inside of the other macro context. I need to think a little about this.
Minimal code (you may need to add some imports, because I carved this snippet from another code):
Error:
The text was updated successfully, but these errors were encountered: