Skip to content

Commit

Permalink
Merge pull request #167 from timholy/teh/===
Browse files Browse the repository at this point in the history
Use === in more places to reduce invalidation
  • Loading branch information
cstjean authored Aug 18, 2021
2 parents 9499252 + 4983478 commit 7bc92b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/match/macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function clauses(ex)
for l in ex.args
isline(l) && (line = l; continue)
env = trymatch(:(pat_ => yes_), l)
env == nothing && error("Invalid match clause $l")
env === nothing && error("Invalid match clause $l")
pat, yes = env[:pat], env[:yes]
push!(clauses, (pat, :($line;$yes)))
end
Expand Down Expand Up @@ -70,7 +70,7 @@ macro capture(ex, pat)
quote
$([:($(esc(b)) = nothing) for b in bs]...)
env = trymatch($(esc(Expr(:quote, pat))), $(esc(ex)))
if env == nothing
if env === nothing
false
else
$([:($(esc(b)) = get(env, $(esc(Expr(:quote, b))), nothing)) for b in bs]...)
Expand Down
2 changes: 1 addition & 1 deletion src/match/match.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ match(::LineNumberNode, ::LineNumberNode, _) = nothing

function match(pat, ex, env)
pat = normalise(pat)
pat == :_ && return env
pat === :_ && return env
isbinding(pat) && return store!(env, bname(pat), ex)
ex = normalise(ex)
pat, ex = blockunify(pat, ex)
Expand Down
2 changes: 1 addition & 1 deletion src/match/union.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ or_(p...) = foldl(or_, p)

function match_inner(pat::OrBind, ex, env)
env′ = trymatch(pat.pat1, ex)
env′ == nothing ? match(pat.pat2, ex, env) : merge!(env, env′)
env′ === nothing ? match(pat.pat2, ex, env) : merge!(env, env′)
end

function isor(ex)
Expand Down

0 comments on commit 7bc92b7

Please sign in to comment.