Skip to content

__file__ is not defined #510

@mtshiba

Description

@mtshiba

From: #508

print! __file__
$ erg test.er    
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "test.er", line -1, in <module>
NameError: name '__file__' is not defined. Did you mean: '__name__'?

Erg does not create files (on Unix) when executing Python bytecode. That is, __file__ is not set. Even if the compiler creates the file, it will be created in the temporary directory, so it won't work as intended anyway.
The compiler must embed the contents of this variable at compile time.


Originally posted by @toddlerer in #508 (comment)

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