Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behaviour when using .xy after a function call #1730

Open
tuket opened this issue Apr 18, 2022 · 1 comment · May be fixed by #4339
Open

Inconsistent behaviour when using .xy after a function call #1730

tuket opened this issue Apr 18, 2022 · 1 comment · May be fixed by #4339
Labels

Comments

@tuket
Copy link

tuket commented Apr 18, 2022

Context

I have made this small code that reproduces the bug:

package main

import "core:fmt"

f :: proc() -> [4][2]string
{
    return {
        {"00", "01"},
        {"10", "11"},
        {"20", "21"},
        {"30", "31"}}
}

main :: proc()
{
    reproBug := true
    if reproBug {        
        for l in f().xy {
            for s in l {
                fmt.println(s)
            }
        }
    }
    else {
        ll := f().xy
        for l in ll {
            for s in l {
                fmt.println(s)
            }
        }
    }
}
  • Operating System & Odin Version:
    Odin: dev-2022-04-nightly:59025b75
    OS: Windows 10 Education (version: 21H1), build 19043.1645
    CPU: AMD Ryzen 7 3700X 8-Core Processor
    RAM: 16332 MiB

Expected Behavior

It should print the following in both branch cases:

00
01
10
11

Current Behavior

When reproBuf := true it prints:

00
01
10
11
20
21
30
31
@github-actions github-actions bot added the stale label Aug 16, 2022
@jaspergeer
Copy link
Contributor

I just want to add that this actually occurs even without the function call.

ll : [4]int = {1,2,3,4}
for l in ll.xxz {
    fmt.println(l)
}

The code above produces the following:

1
2
3
4

Rather than the expected:

1
1
3

However, the following code snippet produces the intended output:

ll : [4]int = {1,2,3,4}
for l in ([3]int)(ll.xxz) {
    fmt.println(l)
}

@github-actions github-actions bot removed the stale label Aug 29, 2022
@github-actions github-actions bot added the stale label Dec 28, 2022
laytan added a commit to laytan/Odin that referenced this issue Oct 2, 2024
@laytan laytan linked a pull request Oct 2, 2024 that will close this issue
laytan added a commit to laytan/Odin that referenced this issue Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants