amber-lang / amber-lang/amber

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

Aberta
#694 1 comentário 0 reações 0 responsáveis Ver no GitHub
bug compiler
Linguagem predominante
Rust
Estrelas
5.2k
Forks
145
Merge médio
5d 3h
PRs com merge (30d)
7

Descrição

**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
```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.