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

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

Closed
jvasileff opened this issue Nov 18, 2014 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@jvasileff
Copy link
Member

Relating to ceylon/ceylon-spec#438 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.

@gavinking gavinking added the BUG label Nov 18, 2014
@gavinking gavinking added this to the 1.1.5 milestone Nov 18, 2014
@FroMage
Copy link
Member

FroMage commented Nov 18, 2014

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

FroMage added a commit that referenced this issue Nov 19, 2014
FroMage added a commit that referenced this issue Nov 19, 2014
…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 19, 2014
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 19, 2014
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
@FroMage
Copy link
Member

FroMage commented Nov 19, 2014

There you go, as you can see it was a piece of cake ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants