Ph0enixKM / Amber

💎 Amber the programming language compiled to bash
https://amber-lang.com
GNU General Public License v3.0
3.51k stars 67 forks source link

🐞 Incorrect value passed to function #229

Open CymDeveloppement opened 1 week ago

CymDeveloppement commented 1 week ago

in this example output not work properly

import { replace_once } from "std"

fun bar(test_a) {
    return test_a
}

fun foo() {
    return replace_once("hello world!", "world", "Amber")
}

echo "foo:" + foo()
let foo_result = foo()
echo "bar:" + bar(foo())
echo "bar_with_foo_result:" + bar(foo_result)

Output :

foo:hello Amber!
bar:hello
bar_with_foo_result:hello Amber!

But normally all result is same I think is the space in "hello world!". the problem disappear when i suppress space

foo:helloAmber!
bar:helloAmber!
bar_with_foo_result:helloAmber!
CymDeveloppement commented 1 week ago

in bash script the function "bar" alias "bar__23_v0" is called without double quotes but it is required

foo__24_v0 ;
__AMBER_FUN_foo24_v0__18=${__AMBER_FUN_foo24_v0};
bar__23_v0 ${__AMBER_FUN_foo24_v0__18};
__AMBER_FUN_bar23_v0__18=${__AMBER_FUN_bar23_v0};
echo "bar:"${__AMBER_FUN_bar23_v0__18};
bar__23_v0 "${__0_foo_result}";
__AMBER_FUN_bar23_v0__19=${__AMBER_FUN_bar23_v0};
echo "bar_with_foo_result:"${__AMBER_FUN_bar23_v0__19}

the problem is the same with typed function foo(): Text and bar(): Text