Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Untyped value to array type

Open JesseRMeyer opened this issue 3 years ago • 2 comments

    bobby :: proc() -> [2]f32 {
      t :: glsl.vec3{0, 1, 0}
      return (t.x >= 0.0) ? 1 : -1, (t.y >= 0.0) ? 1 : -1 //Cannot convert untyped value '(t.x >= 0.0) ? 1 : -1' to '[2]f32' from 'untyped integer'
    }

As discussed in Discord.

JesseRMeyer avatar Mar 27 '23 13:03 JesseRMeyer

Because you're trying to fill [2]f32 with either 1 or -1, and then you have a second ternary for a second return value the proc doesn't have, this was never going to work. { .. } solves it.

bobby :: proc() -> [2]f32 {
	t :: glsl.vec3{0, 1, 0}
	return {(t.x >= 0.0) ? 1 : -1, (t.y >= 0.0) ? 1 : -1} //Cannot convert untyped value '(t.x >= 0.0) ? 1 : -1' to '[2]f32' from 'untyped integer'
}

Kelimion avatar Mar 27 '23 13:03 Kelimion

Thanks. I was expecting the constant system to aid me here, given that x : [2]f32 = 1 works.

JesseRMeyer avatar Mar 27 '23 13:03 JesseRMeyer