Bug
The expression `type_info(type_of(x))` fails because the inner `type_of` expression is not evaluated before being passed to `type_info`. The LLVM backend receives the literal string "type_of" as the type name.
Reproduction
// examples/17/17.14_type_info_variants.jai
add :: (a: int, b: int) -> int { return a + b; }
info := cast(*Type_Info_Procedure) type_info(type_of(add));
Error: `LLVM backend type_info_ptr: unknown type 'type_of'`
Root Cause Analysis
In `bytecode_gen.zig`, when the `type_info` directive processes its argument, it appears to take the source text of the argument node rather than evaluating it. For `type_info(type_of(add))`, the argument node is a `type_of_expr`, and the codegen reads its source text as "type_of" (or "type_of(add)") instead of first evaluating the `type_of` to get the actual type text (e.g., "(a: int, b: int) -> int"), then passing that resolved type to the `type_info` instruction.
The fix needs to:
- Detect when the `type_info` argument is a `type_of_expr`
- Evaluate the inner `type_of` first to get the resolved type text
- Pass that resolved type text to the `type_info` instruction
Files
- `bootstrap/src/bytecode_gen.zig` (type_info handling, likely near type_of_expr handling ~line 5628)
- `bootstrap/src/codegen/llvm.zig` (type_info_ptr emission, ~line 2570)
Bug
The expression `type_info(type_of(x))` fails because the inner `type_of` expression is not evaluated before being passed to `type_info`. The LLVM backend receives the literal string "type_of" as the type name.
Reproduction
Error: `LLVM backend type_info_ptr: unknown type 'type_of'`
Root Cause Analysis
In `bytecode_gen.zig`, when the `type_info` directive processes its argument, it appears to take the source text of the argument node rather than evaluating it. For `type_info(type_of(add))`, the argument node is a `type_of_expr`, and the codegen reads its source text as "type_of" (or "type_of(add)") instead of first evaluating the `type_of` to get the actual type text (e.g., "(a: int, b: int) -> int"), then passing that resolved type to the `type_info` instruction.
The fix needs to:
Files