amber-lang / amber-lang/amber

[BUG] Can't use printf when having an entrypoint at the same time.

Đang mở
#694 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug compiler
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**
When using printf, in combination with an entrypoint (`main(args) {}`), the entrypoint declares a global array named `args`, which comes into conflict with the local variable within `printf`.
Amber: `0.4.0-alpha`

**To Reproduce**
```typescript
#!/bin/env amber

import {printf} from "std/env"

main(args) {
printf("Hi!")
}
```

**Expected behavior**
I'd expect using the std-lib to not cause a name-conflict when using args.

**Additional context**
Here is the resulting `.sh` file
```bash
#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
# version: 0.4.0-alpha
# date: 2025-04-11 20:16:38

printf__99_v0() {
local format=$1
local args=("${!2}")
args=("${format}" "${args[@]}") ;
__AS=$?
printf "${args[@]}" ;
__AS=$?
}
# #!/bin/env amber
declare -r args=("$0" "$@")
__AMBER_ARRAY_0=("");
printf__99_v0 "Hi"'!'"" __AMBER_ARRAY_0[@];
__AF_printf99_v0__6_5="$__AF_printf99_v0";
echo "$__AF_printf99_v0__6_5" > /dev/null 2>&1
```

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á.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.