Description
c_string() does not validate its argument type. Passing an EZ string literal (or any non-pointer value) bypasses the typechecker and produces a C compilation error:
operand of type 'EzString' where arithmetic or pointer type is required
Users should never see C compiler errors.
Repro
do main() {
mut msg = c_string("hello")
println(msg)
}
Expected: Typechecker error — c_string() expects a raw pointer from C interop.
Actual: Falls through to codegen and fails at C compilation.
Root cause
In typechecker.c, c_string is recognized and its return type is set to string, but there's no check that the argument is a pointer type (TK_POINTER). The codegen wraps the EZ string in ez_string_lit() and tries to cast it to const char*, which fails at the C level.
Fix
Add a type check in the typechecker's c_string handler — verify the argument resolves to a pointer type. If not, emit E3083.
Description
c_string()does not validate its argument type. Passing an EZ string literal (or any non-pointer value) bypasses the typechecker and produces a C compilation error:Users should never see C compiler errors.
Repro
Expected: Typechecker error —
c_string()expects a raw pointer from C interop.Actual: Falls through to codegen and fails at C compilation.
Root cause
In
typechecker.c,c_stringis recognized and its return type is set tostring, but there's no check that the argument is a pointer type (TK_POINTER). The codegen wraps the EZ string inez_string_lit()and tries to cast it toconst char*, which fails at the C level.Fix
Add a type check in the typechecker's
c_stringhandler — verify the argument resolves to a pointer type. If not, emit E3083.