Expose local phase levels to rules
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 领域
- tooling
调研方向
首先调查 Resyntax 当前的 expansion observer hook 和源代码分析流程,重点关注访问是如何表示的,以及规则如何获取阶段信息。该 issue 建议向规则公开一个本地阶段级别;完成内容应包括成功重构 begin-for-syntax 示例,同时保持 phase-0 行为不变。
由索引模型根据 Issue 内容生成。
描述
This rule:
(define-refactoring-rule redundant-or
#:description "This `or` expression does nothing and can be replaced with its subexpression."
#:literals (or)
(or a1:id a2:id)
#:when (free-identifier=? #'a1 #'a2)
a1)
Fails to refactor this code:
(begin-for-syntax
(define x 42)
(or x x))
The reason for that is that free-identifier=? checks if two identifiers have the same binding at a specific phase level, and by default it uses (syntax-local-phase-level). This is reasonable for macros, which set (syntax-local-phase-level) to the level of the macro invocation. But refactoring rules aren't run during macro expansion, so (syntax-local-phase-level) always returns zero. This lets free-identifier=? in rules work fine on phase 0 code, but it fails on phase 1 code such as code inside begin-for-syntax.
Resyntax ought to expose the local phase level to rules. I'm not sure how to get that information out of the expander using the current expansion observer hook, but it's probably possible. One way to expose it to rules might be to add a (resyntax-local-phase-level) parameter and let rules use that to access the phase level. On the Resyntax source analysis side, there could be an expansion-visit struct / record type containing the syntax object that the expander visited and the phase level the visit occurred at.
- 主要语言
- Racket
- 星标
- 70
- 派生
- 11
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
jackfirth/resyntax 的其他 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 68/100
-
documentation
难度 4/5 3-5 天 新手友好度 45/100
-
testing
难度 4/5 3-5 天 新手友好度 45/100
-
testing
难度 3/5 1-2 天 新手友好度 75/100
-
testing
难度 4/5 3-5 天 新手友好度 68/100
查看 jackfirth/resyntax 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
stephrobert/dsoxlab#238 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
sublimehq/package_control#1780 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
typelevel/sbt-typelevel#929 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
antfu-collective/icones#398 ·