Skip to content

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

Open
@ArjixWasTaken

Description

@ArjixWasTaken

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

#!/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

#!/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions