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

error on assignment of assignment expression to variable of type Anything #1917

Closed
CeylonMigrationBot opened this issue Nov 18, 2014 · 2 comments

Comments

@CeylonMigrationBot
Copy link

[@jvasileff] Relating to #3544 and ceylon/ceylon-spec@ad195d3

void fails<Result>(Result() f) {
  variable Anything memo;
  Result x = memo = f(); // Ceylon Backend Error
  // incompatible types
  // required: Result
  // found:    java.lang.Object
}

void works<Result>(Result() f) {
  variable Result|Object|Null memo;
  Result x = memo = f();
}

Anything probably doesn't make sense here that often, but it looks like a bug nevertheless. FWIW, the use case involved using a marker object for memo's initial value, to distinguish from a Null result, and eventually doing assert(is Result ...), making the type largely irrelevant.

[Migrated from ceylon/ceylon-compiler#1917]
[Closed at 2014-11-19 10:22:38]

@CeylonMigrationBot
Copy link
Author

[@FroMage] Typical example of @gavinking implementing something and forgetting to open an issue here about it ;)

@CeylonMigrationBot
Copy link
Author

[@FroMage] There you go, as you can see it was a piece of cake ;)

@CeylonMigrationBot CeylonMigrationBot added this to the 1.2 milestone Nov 14, 2015
FroMage added a commit that referenced this issue Nov 14, 2015
FroMage added a commit that referenced this issue Nov 14, 2015
…ng rules for assignment now

Otherwise we get things like

Type x = (Type)
let(
Object tmpvar = nothing;
y = tmpvar; // here we need to add the (Type) cast as well
)
returning tmpvar;

for Type x, y; x = y = nothing
FroMage added a commit that referenced this issue Nov 14, 2015
Because otherwise the Java bottom type is stored in java.lang.Object, which is not
of the bottom type, so x = y = null will fail because null is stored in java.lang.Object
and can't be assigned to either y or x
FroMage added a commit that referenced this issue Nov 14, 2015
I give up on trying to fix this totally unnecessary cast, because it has to do with another
bug related to rawness of tuple types where we consider that they are raw without considering
the fact that in fact they are erased to Sequential, which has far less constraints and rawness
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

2 participants