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

Macro.to_string/2 deprecation warning #115

Closed
florish opened this issue Nov 21, 2022 · 3 comments · Fixed by #126
Closed

Macro.to_string/2 deprecation warning #115

florish opened this issue Nov 21, 2022 · 3 comments · Fixed by #126
Labels

Comments

@florish
Copy link

florish commented Nov 21, 2022

Hi, on running mix compile with Elixir 1.14.2 and Erlang/OTP 25.1, I get the following warning:

==> sobelow
Compiling 51 files (.ex)
warning: Macro.to_string/2 is deprecated. Use Macro.to_string/1 instead
Invalid call found at 2 locations:
  lib/sobelow/print.ex:212: Sobelow.Print.print_code/2
  lib/sobelow/print.ex:226: Sobelow.Print.print_file_path_code/2

Nothing is broken yet, but I figured it would be helpful to open this issue, as this could become problematic in future Elixir versions.

I'm willing to help by opening a PR, but do not have any experience with Macro.to_string/1,2 and/or the sobelow codebase yet, which means I'm not entirely sure which path to follow here.

@houllette houllette added the bug label Jan 6, 2023
@dennym
Copy link

dennym commented Jan 23, 2023

This would be a nice fix. Plenty of github action examples also run mix compile --warnings-as-errors which currently fails due to this.

@houllette
Copy link
Collaborator

I'm still getting familiar with the codebase myself, but have started to dig into this a little bit. Looks like from this comment from @josevalim, we may have to just do a prewalk as sort of a pre-pass on the data.

@josevalim
Copy link

normalize_template_var can be a prewalk pass. Then, for highlighting variables, you could do a prewalk and wrap them into something that will become __sobelow_highlight__(var) when converted to string. Then do a pass on the string and convert the highlight into ascii. :D

Another option is to do something like this: do a prewalk, create a variable named __sobelow_highlight_#{n}__ for each highlight, and then introduce the variable into the AST instead of the highlight. Then you convert to string and then you replace all __sobelow_highlight_N__ in the output by the specific code you want to highlight

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

Successfully merging a pull request may close this issue.

4 participants