Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FunC cannot compile large nested Structs in asm functions #1222

Open
novusnota opened this issue Dec 20, 2024 · 0 comments
Open

FunC cannot compile large nested Structs in asm functions #1222

novusnota opened this issue Dec 20, 2024 · 0 comments
Labels
bug Something isn't working or isn't right func-bug

Comments

@novusnota
Copy link
Member

novusnota commented Dec 20, 2024

Something like this won't pass FunC compilation step, and the user will see an error message from FunC, not Tact:

struct TestLong {
    f1: Bool; f2: Bool; f3: Bool; f4: Bool;
    f5: Bool; f6: Bool; f7: Bool; f8: Bool;
    f9: Bool; f10: Bool; f11: Bool; f12: Bool;
    f13: Bool; f14: Bool; f15: Bool;
    // f16: Bool;
}

struct TestMultiLong {
    f1: TestLong;  // 16
    f2: TestLong;  // 32
    f3: TestLong;  // 48
    f4: TestLong;  // 64 Bools (Ints)
    f5: TestLong;  // 
    f6: TestLong;  // 
    f7: TestLong;  // 
    f8: TestLong;  // 128
    f9: TestLong;  // 
    f10: TestLong; // 
    f11: TestLong; // 
    f12: TestLong; // 
    f13: TestLong; // 
    f14: TestLong; // 
    f15: TestLong; // 256 - 16 - 15 = 225
    // f16: TestLong;
}

// This function won't compile
asm fun testMl(s: TestMultiLong): Bool { } // Bool here is only to avoid
                                           // https://github.com/tact-lang/tact/issues/1201

// Pardon the huge example :)
fun showcase() {
    dump(
         testMl(TestMultiLong{
            f1: TestLong{ f1: false, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f2: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f3: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f4: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f5: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f6: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f7: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f8: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f9: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f10: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f11: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f12: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f13: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f14: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            f15: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
            // f16: TestLong{ f1: true, f2: false, f3: false, f4: false, f5: false, f6: false, f7: false, f8: false, f9: false, f10: false, f11: false, f12: false, f13: false, f14: false, f15: false },
        })
    );
}

Note, that non-asm functions compile in FunC just fine, so the following modification of the asm function above into the global function will produce true:

fun testMl(structure: TestMultiLong): Bool {
    let s = structure;
    return true;
}

And dropping unused values doesn't interfere here, see:

fun testMl(structure: TestMultiLong): TestMultiLong {
    return structure;
}

// and modify the call to `testMl()`, adding the following after its `)`:
// .f1.f1 → which dumps `false` to the debug console
@novusnota novusnota added bug Something isn't working or isn't right func-bug labels Dec 20, 2024
@novusnota novusnota changed the title FunC cannot compile large nested Structs FunC cannot compile large nested Structs in asm functions Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or isn't right func-bug
Projects
None yet
Development

No branches or pull requests

1 participant