question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JS model loader doesn’t understand union type alias in ceylon.ast.core

See original GitHub issue
ceylon compile-js ceylon.ast.samples ceylon.ast.core ceylon.ast.create && ceylon compile-js ceylon.ast.samples

Running this in the ceylon.ast repository on the version-1.3.1 branch, under the 1.3.1 distribution (e. g. from release or built from the 1.3.1 tag) produces 34 errors of the kind:

error: specified expression must be assignable to declared type of ‘expression’: ‘Expression&AssigningExpression’ (‘Expression’) is not assignable to ‘AssigningExpression’ (‘unknown’) error: argument must be assignable to parameter ‘operand’ of ‘NotOperation’: ‘EqualOperation’ is not assignable to ‘NegatingExpression’ (‘unknown’)

It seems the model loader isn’t loading ceylon.ast’s precedence aliases (*ingExpression). @jvasileff reports that ceylon compile-dart, which also uses the JS model loader, has the same problem.

This blocks the ceylon.ast 1.3.1 release.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
jvasileffcommented, Nov 29, 2016

I think @lucaswerkmeister’s reduction is a slightly different case where the class’s parameter’s type winds up with a bad resolvedAliases type, whereas in the original case, it was the type alias’s extended type that had a bad resolvedAliases type.

A further reduction of this second scenario is:

shared class C([ConjoiningExpression, String] children) {}
// resolved type of children becomes: [unknown, String] (type)

shared alias ConjoiningExpression => C|String;

and

import tmp {...}

void run() {
    C(["", ""]);
}

Note that this one is sensitive to ordering; renaming the alias can cause the error to disappear.

1reaction
lucaswerkmeistercommented, Nov 29, 2016

Thanks for investigating this! I managed to boil it down to a shorter example:

// module tmp
shared class UIdentifier() {
    shared void transform(Transformer t) {}
}
shared class AndOperation(children) {
    shared [ConjoiningExpression, NegatingExpression] children;
}
shared interface Transformer {
    shared formal void transformUIdentifier(UIdentifier that);
}
shared alias ConjoiningExpression => AndOperation|UIdentifier;
shared alias NegatingExpression => UIdentifier;

// module tmp2
import tmp {
    UIdentifier,
    AndOperation
}
shared void run() {
    value ui = UIdentifier();
    value ao = AndOperation([ui, ui]);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Refine to type alias in union - Stack Overflow
First I'm gonna walk through this code just to clarify what's going on: type A = { a: number } type B =...
Read more >
[Feature Request] Future-proof always-aliasing/never ... - GitHub
The idea is to create a new type alias that is a union of the original type and the new union elements. However,...
Read more >
Type aliases and type inference - Eclipse Ceylon
In this chapter, we're going to discuss type aliases and local type ... If you need to create an alias for a union...
Read more >
Elm Models as Types - Charlie Koster - Medium
Elm Models as Types. An idea for using Union Types over Type Aliases. I'm building a small single page application for managing Lightning...
Read more >
Type Aliases vs Interfaces in TypeScript - DEV Community ‍ ‍
Type aliases can be used to represent not only primitives but also object types, union types, tuples and intersections.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found