Skip to content

fix: LHS of pointer assignments can only be pointer arithmetic operations#428

Merged
ckirsch merged 1 commit intocksystemsteaching:mainfrom
GGBOIH250:main
Apr 18, 2026
Merged

fix: LHS of pointer assignments can only be pointer arithmetic operations#428
ckirsch merged 1 commit intocksystemsteaching:mainfrom
GGBOIH250:main

Conversation

@GGBOIH250
Copy link
Copy Markdown
Contributor

In compile_assignment the ltype is an expression and can be changed to ltype = compile_arithmetic() as we only have pointer arithmetic or identifier dereferencing on the left hand side of assignments in C*. The default implementation from selfie compiles this with only warnings and no errors:

int main() {
    int *x;
    int *y;

    *(x == y) = 12;

    return 0;
}

Although running this results in a segfault, I find that compiling it successfully is also not ideal. Changing it to ltype = compile_arithmetic() in compile_assignment, the self compilation doesn't break under make self and make self-self and it returns syntax error when above code is now tried to compile.

@ckirsch ckirsch merged commit c44b418 into cksystemsteaching:main Apr 18, 2026
4 checks passed
@ckirsch
Copy link
Copy Markdown
Member

ckirsch commented Apr 18, 2026

@GGBOIH250 thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants