Skip to content

Treat special case of Bool in promote_rule #260

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fatteneder
Copy link
Contributor

Fix #146.

@@ -82,6 +82,7 @@ Basic(x::Basic) = x
Base.promote_rule(::Type{Basic}, ::Type{S}) where {S<:Number} = Basic
Base.promote_rule(::Type{S}, ::Type{Basic}) where {S<:Number} = Basic
Base.promote_rule(::Type{S}, ::Type{Basic}) where {S<:AbstractIrrational} = Basic
Base.promote_rule(::Type{Bool}, ::Type{Basic}) = Basic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should promote true to 1 or True in SymEngine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is a good question. Right now, neither True or False values are exposed. If True, is there some idiomatic way to make an expression like this evaluate to a number?

julia> True = Basic();

julia> ccall((:bool_set_true, SymEngine.libsymengine), Nothing, (Ref{Basic},), True)

julia> v = Basic(4) + True
4 + True

julia> SymEngine.evalf(v)
ERROR: ArgumentError: symbolic value cannot be evaluated to a numeric value

@jverzani jverzani mentioned this pull request Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Method ambiguity for promote_rule(Type{Boo},::Type{Basic})
3 participants