thelilylang / lily

The Lily programming language ⚜
MIT License
9 stars 2 forks source link

Fix escape character generation #519

Closed ArthurPV closed 2 months ago

ArthurPV commented 2 months ago

This type of code produced bad generation code:

#include <assert.h>

int main() {
    assert(0 && "error");
}

generate that:

[[noreturn]] extern void __assert_fail(const char* __assertion, const char* __file, unsigned int __line, const char* __function);
[[noreturn]] extern void __assert(const char* __assertion, const char* __file, int __line);
int main();

int main() {
    (0 && "error") ? ((void)0) : __assert_fail("0 && "error"", "assert.h", 53, __func__);
}

and now what's generated after the fix:

[[noreturn]] extern void __assert_fail(const char* __assertion, const char* __file, unsigned int __line, const char* __function);
[[noreturn]] extern void __assert(const char* __assertion, const char* __file, int __line);
int main();

int main() {
    (0 && "error") ? ((void)0) : __assert_fail("0 && \"error\"", "assert.h", 53, __func__);
}