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

[BUG] Concate value on print generate wrong bash #427

Open
Mte90 opened this issue Aug 30, 2024 · 4 comments
Open

[BUG] Concate value on print generate wrong bash #427

Mte90 opened this issue Aug 30, 2024 · 4 comments
Labels
bug Something isn't working compiler

Comments

@Mte90
Copy link
Member

Mte90 commented Aug 30, 2024

An example code:

pub fun round(number: Num): Num {
    let operator = "+"
    if number > 0 {
        operator = "-"
    }

    return unsafe $echo "({number}{operator}0.5)/1" | bc$ as Num
}

Generates:

round__1_v0() {
    local number=$1
    local operator="+"
    if [ $(echo ${number} '>' 0 | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//') != 0 ]; then
        operator="-"
    fi
    __AMBER_VAL_0=$(echo "(${number}0.5)/1" | bc${operator})
    __AS=$?
    __AF_round1_v0="${__AMBER_VAL_0}"
    return 0
}
@Mte90 Mte90 added bug Something isn't working compiler labels Aug 30, 2024
@b1ek
Copy link
Member

b1ek commented Aug 30, 2024

so.. what's the problem?

@Mte90
Copy link
Member Author

Mte90 commented Aug 30, 2024

The line:

    __AMBER_VAL_0=$(echo "(${number}0.5)/1" | bc${operator})

Is wrong.

It should be:

    __AMBER_VAL_0=$(echo "(${number}${operator}0.5)/1" | bc)

@b1ek
Copy link
Member

b1ek commented Aug 31, 2024

huh.. that is like super weird

@Ph0enixKM
Copy link
Member

I think I know what's the problem and how to fix it. But I have to test it first on my machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler
Projects
None yet
Development

No branches or pull requests

3 participants