Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Generation: Include file and line attribute #3149

Open
inoas opened this issue May 17, 2024 · 1 comment
Open

Code Generation: Include file and line attribute #3149

inoas opened this issue May 17, 2024 · 1 comment
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium

Comments

@inoas
Copy link
Contributor

inoas commented May 17, 2024

This would allow jumping from the generated source code to the gleam source file.

On target Erlang the file attribute could be used:

Setting File and Line

The same syntax as for module attributes is used for changing the pre-defined macros ?FILE and ?LINE:

-file(File, Line).

This attribute is used by tools, such as Yecc, to inform the compiler that the source program is generated by another tool. It also indicates the correspondence of source files to lines of the original user-written file, from which the source program is produced.

Source: https://www.erlang.org/doc/reference_manual/modules#setting-file-and-line

As one effect, this would help tools like stacky to allow jumping into the gleam source file from the stack trace.

  • On target JS if there is any standard solution, that could be used? Otherwise we can just setup a convention?
  • Optional: Maybe the compiler could be told to not include such details for security reasons, by a compiler flag, or is this a no-issue if the pathes are relative not absolute?
@lpil
Copy link
Member

lpil commented May 17, 2024

On target JS if there is any standard solution, that could be used?

On JS they use sourcemaps, which is a much better solution and will give perfect results. We have an issue for this.

@lpil lpil added help wanted Contributions encouraged good first issue Good for newcomers priority:medium labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium
Projects
None yet
Development

No branches or pull requests

2 participants