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

Recursive alias does not match non generic subclass of generic type #1473

Closed
jeromegn opened this issue Sep 14, 2015 · 3 comments
Closed

Recursive alias does not match non generic subclass of generic type #1473

jeromegn opened this issue Sep 14, 2015 · 3 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler

Comments

@jeromegn
Copy link
Contributor

(Was: Adding a K => V to a Hash subclass is not possible with certain types)

In short: With a subclassed (and permissive of many types) Hash, it's not always possible to add certain types of values to it.

Demonstation: http://play.crystal-lang.org/#/r/fbe

I lack the words to explain it better so hopefully the linked demo is self-explanatory.

Is this a bug, a feature or a missing feature?

@jhass jhass changed the title Adding a K => V to a Hash subclass is not possible with certain types Recursive alias does not match non generic subclass of generic type (Was: Adding a K => V to a Hash subclass is not possible with certain types) Sep 14, 2015
@jhass jhass changed the title Recursive alias does not match non generic subclass of generic type (Was: Adding a K => V to a Hash subclass is not possible with certain types) Recursive alias does not match non generic subclass of generic type Sep 14, 2015
@jhass jhass added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Sep 14, 2015
@pgkos
Copy link
Contributor

pgkos commented Sep 15, 2015

A similar issue:

ary = [] of Array(String | Char) | Array(Int32 | Float64)
ary << ["abc", 'd']  # works
ary << ["abc", "def"]  # does not compile

but this works:

ary = [] of Array(String | Char)
ary << ["abc", 'd']  # works
ary << ["abc", "def"]  # also works

@jeromegn
Copy link
Contributor Author

Something is odd. I just realized I'm able to assign a key to a Array(BSON::Document) fine when I generate the document from the bson source.

Essentially, this this value of the document will make an Array(BSON::Document | String | Int32 | Bool | BSON::ObjectId). Later on, it'll be inserted in the document.

I'm not sure that would suddenly work...

I created a new playground code example http://play.crystal-lang.org/#/r/fix which shows how it works if the array's type is specified beforehand.

@asterite
Copy link
Member

Closed in favor of #2665

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Projects
None yet
Development

No branches or pull requests

4 participants