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 === instead of == to compare Symbols #4622

Merged
merged 1 commit into from
Jan 6, 2023
Merged
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
12 changes: 6 additions & 6 deletions RecipesBase/src/RecipesBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ _is_arrow_tuple(expr::Expr) =
expr.head ≡ :tuple &&
!isempty(expr.args) &&
isa(expr.args[1], Expr) &&
expr.args[1].head == :(-->)
expr.args[1].head === :(-->)

_equals_symbol(x::Symbol, sym::Symbol) = x == sym
_equals_symbol(x::QuoteNode, sym::Symbol) = x.value == sym
_equals_symbol(x::Symbol, sym::Symbol) = x === sym
_equals_symbol(x::QuoteNode, sym::Symbol) = x.value === sym
_equals_symbol(x, sym::Symbol) = false

# build an apply_recipe function header from the recipe function header
Expand Down Expand Up @@ -112,7 +112,7 @@ function create_kw_body(func_signature::Expr)
if isa(arg1, Expr) && arg1.head ≡ :parameters
for kwpair in arg1.args
k, v = kwpair.args
if isa(k, Expr) && k.head == :(::)
if isa(k, Expr) && k.head === :(::)
k = k.args[1]
@warn """
Type annotations on keyword arguments not currently supported in recipes.
Expand Down Expand Up @@ -163,14 +163,14 @@ function process_recipe_body!(expr::Expr)

# the unused operator `:=` will mean force: `x := 5` is equivalent to `x --> 5, force`
# note: this means "x is defined as 5"
if e.head == :(:=)
if e.head === :(:=)
force = true
e.head = :(-->)
end

# we are going to recursively swap out `a --> b, flags...` commands
# note: this means "x may become 5"
if e.head == :(-->)
if e.head === :(-->)
k, v = e.args
if isa(k, Symbol)
k = QuoteNode(k)
Expand Down