[BUG] ternary executes the function disregarding of the condition result
- Ngôn ngữ chính
- Rust
- Star
- 5.2k
- Fork
- 145
- Merge trung bình
- 5 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 7
Mô tả
**Describe the bug**
any ternary expression will execute the function on either result of the condition if the true or false part includes a function
**To Reproduce**
```
fun test(): Text {
echo("executed")
return "bar"
}
main (args) {
echo(
len(args) >= 1 then "foo" else test() // always true, to show that the function is function is executed either way
)
}
```
returns:
```
executed
foo
```
**Expected behavior**
```
foo
```
**Additional context**
the issue is caused by `src/modules/function/invocation.rs` automatically pushing the function execution back into query during translation in `src/expression/ternop/ternary.rs`, where only the return variable is then generated
```sh
test__0_v0
ret_test0_v0__7_27="${ret_test0_v0}"
printf '%s\n' "$(if (( 2 > 1 )); then echo "foo"; else echo "${ret_test0_v0__7_27}"; fi)"
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.