Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use === in more places to reduce invalidation #167

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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