ArachnidAbby / BCL

BCL Compiled Language (BCL)
https://discord.gg/sShr7fMNFn
GNU General Public License v3.0
21 stars 0 forks source link

[BUG] The compiler needs to do return coupling #10

Closed ArachnidAbby closed 1 year ago

ArachnidAbby commented 1 year ago

Describe the bug The current method of determining return lifetimes allows you to reset the lifetimes of a pointer. This causes lots of bugs, like being able to store short lived data in them.

To Reproduce

struct Container {
    x: &i32;
}

define reset_lifetime(x: &Container) -> &Container {
    return x;
}

define gets_lifetime(x: &Container) {
    reset_lifetime(x).x = &12; // not possible via `x.x = &12;`
}

Expected behavior The return lifetime should be coupled to the lifetime of it's returned arguments.

Error given, or a screenshot of the bug

N/A

platform information

compiler-version: 0.7.0
os: Linux-x64

Additional context You goofy bastard, fix this.

ArachnidAbby commented 1 year ago

I am surprised that it wasn't very hard to add this.

^^ don't quote me on this later if it breaks.

Fixed: eb46ce5