lifting from within user-defined macros can break compilation
还没有人认领这个 Issue。
评估
调研方向
首先在 main 上复现 Example Input,并检查 styler 如何通过嵌套的 do-blocks 提升 aliases,以及如何处理 quote children。比较两个提议的修复方案,然后验证使用用户定义宏的代码仍能编译,且不存在未使用的外部 alias 或宏内部的未定义名称。
由索引模型根据 Issue 内容生成。
描述
Versions
currently on main, but 0.12 when it gets cut
Example Input
lifting is smart enough to not interact with quote children, but user-defined macros can hide that that's occurring.
defmodule Foo do
@moduledoc false
my_quote do
alias AliasFor.In.MyQuote
... Foo.Bar.Baz...
... Foo.Bar.Baz ...
end
end
results in:
defmodule Foo do
@moduledoc false
alias Foo.Bar.Baz
my_quote do
alias AliasFor.In.MyQuote
... Baz...
... Baz ...
end
end
but as with quote, the compiler will warn that Baz is unused within Foo, and anything that uses my_quote will then error on Baz being undefined
as-is, the user will have to put the alias where it belongs inside my_quote, which styler is just fine with and will leave be. still, i'd like styler to not leave a codebase uncompilable, even if it just requires a simple human fix
Fix
I see two possible
- never go into do blocks of unknown parents looking for liftable aliases (allowlist all kernel forms and nothing else)
- when a do-block contains a module directive, assume that it's equivalent to a
quoteblock and back out of it
there are pros and cons to each, but 2 probably gives the more correct result, with the downside being a more complex look-ahead implementation. actually, the real win might be doing a combination of both: when encounter directives in a nested scope, figure out if it's a known block parent. if it is, carry on. if it's not, assume this works as a quote does and don't lift
- 主要语言
- Elixir
- 星标
- 810
- 派生
- 46
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
Good first issue: add elixir-phoenix-liveview stack budget preset (Elixir + Phoenix 1.8 + LiveView)未关闭enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
elixir priority-2 T5m technical user-feedback
难度 1/5 1 小时以内 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 82/100
wanderer-industries/wanderer#687 ·
-
Add Holistic Mentorship Dictation Usage Records table (af_lms#500)可能已有人在做 @deepansh96 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
avantifellows/db-service#857 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 79/100
FarmBot/farmbot_os#1530 ·