Skip to content

Real and Imag builtin functions cause parsing errors #5964

@149-code

Description

@149-code

The following code results in a parser error where the builtins 'real' and 'imag' autocast into the wrong data type. The following code produces there error message: Error: '3.2' truncated to 'i8', got 3.200000 fmt.println(i8(real(x) / 3.2)).

package main

import "core:fmt"

main :: proc()
{
	x: complex128 = 10

	fmt.println(i8(real(x) / 3.2))
}

Note that this doesn't happen with other functions for example the following code produces the expected result

package main

import "core:fmt"

my_func :: proc(x: complex128) -> f64
{
	return real(x)
}

main :: proc()
{
	x: complex128 = 10

	fmt.println(i8(my_func(x) / 3.2))
}

Additional Information:
Odin: dev-2025-11:e5153a937
OS: macOS Tahoe 26.0.1 (build 25A362, kernel 25.0.0)
CPU: Apple M2
RAM: 8192 MiB
Backend: LLVM 21.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions