[BUG] function with no return generate useless bash code
Take this code:
fun something() {
echo "yes"
}
something()
It will generated:
#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
# version: 0.3.4-alpha
# date: 2024-07-30 12:41:18
function something__0_v0 {
echo "yes"
}
something__0_v0
__AF_something0_v0__5_1="$__AF_something0_v0"
echo "$__AF_something0_v0__5_1" >/dev/null 2>&1
As we can see the function doesn't have any return so the last 2 lines are not needed.
The code involved is https://github.com/amber-lang/amber/blob/435d91c4aabce2bd016db77313b221eec38a6a65/src/modules/function/invocation.rs#L158
Basically print that also if the function doesn't have any return.
i dont know if we can do this without breaking apart the whole compiler. its kind of like google translate, really
Yeah this is something for @Ph0enixKM that knows how works.
I think that this is the moment when we should add that optimization I explained before:
https://www.youtube.com/watch?v=_caXIMxrYj8&feature=youtu.be
This would solve this issue too.
This is fixed by #706. The amber code is now compiled to:
#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
# version: 0.4.0-alpha-23-g06c34fe
# date: 2025-06-22 07:47:51
something__0_v0() {
echo "yes"
}
something__0_v0