Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Assignment of constant to array in return value causes code generation problem.

Open mtarik34b opened this issue 1 year ago • 1 comments

Operating System & Odin Version:

Odin:    dev-2024-05:e1c4b9b06
OS:      Ubuntu 22.04.4 LTS, Linux 6.5.0-35-generic
Backend: LLVM 18.1.6

This code...

package pkg
import "core:math"
bug :: proc() -> (array: [10]f64 = math.F64_EPSILON) { return }
main :: proc() {}

leads to this error:

Error: Use of import 'math' not in selector 
        bug :: proc() -> (array: [10]f64 = math.F64_EPSILON) { return } 
                                           ^~~^ 

I've tried with other constants of math package and got the same error.


This one with math.INF_F64 is a segfault (the proc has to be called, though):

package pkg
import "core:math"
bug :: proc() -> (array: [10]f64 = math.INF_F64) { return }
main :: proc() {
    bug()
}
Segmentation fault (core dumped)
// or segfault with random number, like:
140736674648336Segmentation fault (core dumped)

mtarik34b avatar May 25 '24 16:05 mtarik34b

This is two separate bugs. The first is a semantic checking bug. The second appears to be a code generation bug.

gingerBill avatar May 26 '24 11:05 gingerBill