Skip to content

Wrong file+line when module attribute aliases are expanded #13819

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

Closed
josevalim opened this issue Sep 10, 2024 · 1 comment
Closed

Wrong file+line when module attribute aliases are expanded #13819

josevalim opened this issue Sep 10, 2024 · 1 comment

Comments

@josevalim
Copy link
Member

josevalim commented Sep 10, 2024

alias My.Schema.User
alias My.Schema.Account
@module_map %{
  account: Account,
  user: User,
  ...
}

IIRC correctly these do not generate compile time dependencies if the attributes are used inside a function only. Run mix trace to double check though.

Wow, I double-checked because I also thought these generated compile-time dependencies, and of course you are correct, very nice. The output that mix trace gives is a bit surprising, it lists at the end of a file with "nofile:" as the source, e.g., when line 28 uses the @example to call a function of a module

Compiling 1 file (.ex)
lib/my_file.ex:5: require MyApp.Something... (export)
lib/my_file.ex:5: call MyApp.Something.../1 (compile)
lib/my_file.ex:11: alias MyApp.Something... (runtime)
lib/my_file.ex:27: alias MyApp.Something... (runtime)
lib/my_file.ex:48: alias MyApp.Something... (runtime)
...
lib/my_file.ex:282: call MyApp.Something.../2 (runtime)
lib/my_file.ex:283: call MyApp.Something.../2 (runtime)
nofile:27: alias MyApp.Something... (compile)

Originally commented at #13762 (comment)

@josevalim
Copy link
Member Author

Closed in 4104bfc, I used the wrong reference.

Unfortunately we don't have the file information at that point, but I made it point to @attrname:LINE:, where the line is where it is accessed (not where it is defined).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant