Skip to content

Commit 12ceddd

Browse files
committed
Small tweaks
1 parent 8da7305 commit 12ceddd

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/compat.jl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Expr-producing macros. Always prefer re-parsing source text over using this.
2020
Supports parsed and/or macro-expanded exprs, but not lowered exprs
2121
"""
2222
function expr_to_syntaxtree(@nospecialize(e),
23-
mctx::Union{MacroExpansionContext, Nothing}=nothing,
24-
lnn::Union{LineNumberNode, Nothing}=nothing)
25-
graph = if isnothing(mctx)
23+
lnn::Union{LineNumberNode, Nothing}=nothing,
24+
ctx=nothing)
25+
graph = if isnothing(ctx)
2626
ensure_attributes!(SyntaxGraph(),
2727
kind=Kind, syntax_flags=UInt16,
2828
source=SourceAttrType, var_id=Int, value=Any,
2929
name_val=String, is_toplevel_thunk=Bool)
3030
else
31-
mctx.graph
31+
syntax_graph(ctx)
3232
end
3333
toplevel_src = if isnothing(lnn)
3434
# Provenance sinkhole for all nodes until we hit a linenode
@@ -154,7 +154,7 @@ function _insert_convert_expr(@nospecialize(e), graph::SyntaxGraph, src::SourceA
154154
return (st_id, src)
155155
elseif e isa Symbol
156156
st_id = _insert_tree_node(graph, K"Identifier", src)
157-
setattr!(graph, st_id, name_val=String(e))
157+
setattr!(graph, st_id; name_val=String(e))
158158
if !Base.isoperator(e) && !Base.is_valid_identifier(e)
159159
return _insert_var_str(st_id, graph, src)
160160
end
@@ -368,10 +368,8 @@ function _insert_convert_expr(@nospecialize(e), graph::SyntaxGraph, src::SourceA
368368
# produce these and they would historically be accepted by flisp lowering.
369369
if e.head === Symbol("latestworld-if-toplevel")
370370
st_k = K"latestworld_if_toplevel"
371-
elseif e.head === :escape || e.head === Symbol("hygienic-scope")
372-
@assert nargs >= 1
373-
# Existing behaviour appears to just ignore any extra args
374-
return _insert_convert_expr(e.args[1], graph, src)
371+
elseif e.head === Symbol("hygienic-scope")
372+
st_k = K"hygienic_scope"
375373
elseif e.head === :meta
376374
# Messy and undocumented. Sometimes we want a K"meta".
377375
@assert e.args[1] isa Symbol

src/kinds.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ function _register_kinds()
4949
# Internal initializer for struct types, for inner constructors/functions
5050
"new"
5151
"splatnew"
52+
# For expr-macro compatibility; gone after expansion
53+
"escape"
54+
"hygienic_scope"
5255
# Catch-all for additional syntax extensions without the need to
5356
# extend `Kind`. Known extensions include:
5457
# locals, islocal

0 commit comments

Comments
 (0)