Skip to content

Adding --out:exe_name flag to a bare nimscript crashes compilation #17438

Open
@monkey-w1n5t0n

Description

@monkey-w1n5t0n

Compiling with nim c --out:hello_world main.nim works fine, but adding the --out:hello_world flag to main.nims crashes compilation.

Example

Contents of a recreate.sh shell script:

mkdir recreate_bug && cd recreate_bug

# This works
echo "echo(\"hello world\")" > main.nim
echo "--run" > main.nims
nim c main.nim 

# This also works
nim c --out:hello_world main.nim 

# This doesn't work :(
echo "--out:hello_world" >> main.nims
nim c main.nim

Current Output

(comments added for clarity)

~/code/bug $ ./recreate.sh
## First
Hint: used config file 'C:\Program Files\Nim\nim-1.4.4\config\nim.cfg' [Conf]
Hint: used config file 'C:\Program Files\Nim\nim-1.4.4\config\config.nims' [Conf]
....
Hint:  [Link]
Hint: 29919 lines; 0.514s; 31.738MiB peakmem; Debug build; proj: C:\Users\Scored\code\bug\recreate_bug\main.nim; out: C:\Users\Scored\code\bug\recreate_bug\main.exe [SuccessX]
Hint: C:\Users\Scored\code\bug\recreate_bug\main.exe  [Exec]
hello world

## Second
Hint: used config file 'C:\Program Files\Nim\nim-1.4.4\config\nim.cfg' [Conf]
Hint: used config file 'C:\Program Files\Nim\nim-1.4.4\config\config.nims' [Conf]
....
Hint:  [Link]
Hint: 29919 lines; 0.506s; 31.785MiB peakmem; Debug build; proj: C:\Users\Scored\code\bug\recreate_bug\main.nim; out: C:\Users\Scored\code\bug\recreate_bug\hello_world [SuccessX]
Hint: C:\Users\Scored\code\bug\recreate_bug\hello_world  [Exec]
hello world

## Third
Hint: used config file 'C:\Program Files\Nim\nim-1.4.4\config\nim.cfg' [Conf]
Hint: used config file 'C:\Program Files\Nim\nim-1.4.4\config\config.nims' [Conf]
fatal.nim(49)            sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]

Expected Output

## Third should also produce an executable named hello_world and run it to print hello world.

Additional Information

Windows 10 Home (using git-bash to run the script)

$ nim -v
Nim Compiler Version 1.4.4 [Windows: amd64]
Compiled at 2021-02-23
Copyright (c) 2006-2020 by Andreas Rumpf

active boot switches: -d:release

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions