@@ -69,7 +69,7 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
69
69
headsym = ! isnothing (headstr) ? Symbol (headstr) :
70
70
error (" Can't untokenize head of kind $(nodekind) " )
71
71
end
72
- if headsym == :string || headsym == :cmdstring
72
+ if headsym === :string || headsym = == :cmdstring
73
73
# Julia string literals may be interspersed with trivia in two situations:
74
74
# 1. Triple quoted string indentation is trivia
75
75
# 2. An \ before newline removes the newline and any following indentation
@@ -93,7 +93,7 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
93
93
end
94
94
else
95
95
e = _to_expr (node_args[i])
96
- if e isa String && headsym == :string
96
+ if e isa String && headsym === :string
97
97
# Wrap interpolated literal strings in (string) so we can
98
98
# distinguish them from the surrounding text (issue #38501)
99
99
# Ie, "$("str")" vs "str"
@@ -117,22 +117,22 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
117
117
end
118
118
119
119
# Convert children
120
- insert_linenums = (headsym == :block || headsym == :toplevel ) && need_linenodes
120
+ insert_linenums = (headsym === :block || headsym = == :toplevel ) && need_linenodes
121
121
args = Vector {Any} (undef, length (node_args)* (insert_linenums ? 2 : 1 ))
122
- if headsym == :for && length (node_args) == 2
122
+ if headsym === :for && length (node_args) == 2
123
123
# No line numbers in for loop iteration spec
124
124
args[1 ] = _to_expr (node_args[1 ], iteration_spec= true , need_linenodes= false )
125
125
args[2 ] = _to_expr (node_args[2 ])
126
- elseif headsym == :let && length (node_args) == 2
126
+ elseif headsym === :let && length (node_args) == 2
127
127
# No line numbers in let statement binding list
128
128
args[1 ] = _to_expr (node_args[1 ], need_linenodes= false )
129
129
args[2 ] = _to_expr (node_args[2 ])
130
130
else
131
131
eq_to_kw_in_call =
132
- ((headsym == :call || headsym == :dotcall ) && is_prefix_call (node)) ||
133
- headsym == :ref
134
- eq_to_kw_all = headsym == :parameters && ! map_kw_in_params
135
- in_vcbr = headsym == :vect || headsym == :curly || headsym == :braces || headsym == :ref
132
+ ((headsym === :call || headsym = == :dotcall ) && is_prefix_call (node)) ||
133
+ headsym === :ref
134
+ eq_to_kw_all = headsym === :parameters && ! map_kw_in_params
135
+ in_vcbr = headsym === :vect || headsym === :curly || headsym === :braces || headsym = == :ref
136
136
if insert_linenums && isempty (node_args)
137
137
push! (args, source_location (LineNumberNode, node. source, node. position))
138
138
else
@@ -143,8 +143,7 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
143
143
end
144
144
eq_to_kw = eq_to_kw_in_call && i > 1 || eq_to_kw_all
145
145
args[insert_linenums ? 2 * i : i] =
146
- _to_expr (n, eq_to_kw= eq_to_kw,
147
- map_kw_in_params= in_vcbr)
146
+ _to_expr (n, eq_to_kw= eq_to_kw, map_kw_in_params= in_vcbr)
148
147
end
149
148
if nodekind == K " block" && has_flags (node, PARENS_FLAG)
150
149
popfirst! (args)
@@ -197,7 +196,7 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
197
196
end
198
197
elseif headsym === :where
199
198
reorder_parameters! (args, 2 )
200
- elseif headsym == :parens
199
+ elseif headsym === :parens
201
200
# parens are used for grouping and don't appear in the Expr AST
202
201
return only (args)
203
202
elseif headsym in (:try , :try_finally_catch )
@@ -245,15 +244,15 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
245
244
pushfirst! (args, numeric_flags (flags (node)))
246
245
elseif headsym === :typed_ncat
247
246
insert! (args, 2 , numeric_flags (flags (node)))
248
- # elseif headsym == :string && length(args) == 1 && version <= (1,5)
247
+ # elseif headsym === :string && length(args) == 1 && version <= (1,5)
249
248
# Strip string from interpolations in 1.5 and lower to preserve
250
249
# "hi$("ho")" ==> (string "hi" "ho")
251
250
elseif headsym === :(= ) && ! is_decorated (node)
252
251
if is_eventually_call (args[1 ]) && ! iteration_spec && ! Meta. isexpr (args[2 ], :block )
253
252
# Add block for short form function locations
254
253
args[2 ] = Expr (:block , loc, args[2 ])
255
254
end
256
- elseif headsym == :elseif
255
+ elseif headsym === :elseif
257
256
# Block for conditional's source location
258
257
args[1 ] = Expr (:block , loc, args[1 ])
259
258
elseif headsym === :(-> )
@@ -283,7 +282,7 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
283
282
elseif headsym === :module
284
283
pushfirst! (args, ! has_flags (node, BARE_MODULE_FLAG))
285
284
pushfirst! (args[3 ]. args, loc)
286
- elseif headsym == :inert || (headsym == :quote && length (args) == 1 &&
285
+ elseif headsym === :inert || (headsym = == :quote && length (args) == 1 &&
287
286
! (a1 = only (args); a1 isa Expr || a1 isa QuoteNode ||
288
287
a1 isa Bool # <- compat hack, Julia 1.4+
289
288
))
0 commit comments