Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Decimal == AnythingElse causes assertion failure #711

Closed
kingjon3377 opened this issue Sep 8, 2018 · 3 comments
Closed

Decimal == AnythingElse causes assertion failure #711

kingjon3377 opened this issue Sep 8, 2018 · 3 comments

Comments

@kingjon3377
Copy link

Running the following method causes an assertion failure at runtime.

shared void run() {
    if (decimalNumber(3) == 2) {
        process.writeLine("3 == 2");
    } else {
        process.writeLine("3 != 2");
    }
}

The stack trace begins

Exception in thread "main" ceylon.language.AssertionError "Assertion failed
        violated is DecimalImpl that
                expression has type ceylon.language::Integer which is not a subtype of ceylon.decimal::DecimalImpl"
        at ceylon.decimal.DecimalImpl.equals(DecimalImpl.ceylon:123)
        at decimal.run_.run(mwe.ceylon:5)

(The code above is obviously dubious, as an Integer constant and the result of a method returning Decimal are of disjoint types, and in fact the compiler warns about this; where I ran into this, my code was comparing two objects' corresponding fields of declared type Number<out Anything>.)

kingjon3377 added a commit to kingjon3377/strategicprimer-viewer that referenced this issue Sep 8, 2018
kingjon3377 added a commit to kingjon3377/strategicprimer-viewer that referenced this issue Sep 8, 2018
@jvasileff
Copy link
Contributor

@jvasileff
Copy link
Contributor

Fixed!

@gavinking
Copy link
Contributor

Thanks @jvasileff 👍

kingjon3377 added a commit to kingjon3377/strategicprimer-viewer that referenced this issue Sep 15, 2018
kingjon3377 added a commit to kingjon3377/strategicprimer-viewer that referenced this issue Sep 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants