pervognsen / bitwise

Bitwise is an educational project where we create the software/hardware stack for a computer from scratch.
Other
5.14k stars 212 forks source link

Field of a function return value not treated as an l-value #34

Closed mcavanagh closed 6 years ago

mcavanagh commented 6 years ago
struct Thing { a: int; }
func returns_ptr(): Thing*;

func set_value(): void
{
    returns_ptr().a = 5;
}

produces

error: Cannot assign to non-lvalue

Is this intended? Currently resorted to doing

func set_value(): void
{
        thing := returns_ptr();
        thing.a = 5;
}
pervognsen commented 6 years ago

Yes, this is a bug. I'm doing the auto-deref logic after the lvalue check. Stay tuned for a fix.

pervognsen commented 6 years ago

Fixed.