-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
unexpected ',' in type #6980
Comments
You have to do what the error message tells you :-) module Test
class Foo; end
class Bar; end
TYPES = {
Foo => ([] of Symbol),
Bar => ([] of Symbol)
}
end The reason of the error is that |
Or use the classic syntax to create a new class instance: module Test
class Foo; end
class Bar; end
TYPES = {
Foo => Array(Symbol).new,
Bar => Array(Symbol).new
}
end |
@asterite @j8r Well now the new problem is i get: undefined macro method 'Call#map'
CrSerializer::Assertions::NotNil => Array(Symbol).new, and undefined macro method 'Expressions#map'
CrSerializer::Assertions::NotNil => ([] of Symbol), Since im iterating over the key/values (extra code removed for simplicity), and wanting to map the values in the array. tl;dr of this is im using it to new up classes that correspond with the name of the annotation. {% for ivar in @type.instance_vars %}
{% for t, v in CrSerializer::Assertions::TYPES %}
{% ann = ivar.annotation(t.resolve) %}
{% if ann %}
{{v.map { |f| ann[f] }.join(',').id}}
{% end %}
{% end %}
{% end %} Ideally this would be a lot cleaner if you could iterate over all the annotations on an ivar, and iterate on keys of the annotation, but that would prob be best for another issue. |
For now i guess i'll just add a dummy var to the array and just do nothing with it in the initializer. |
For future reference, solution was to do |
https://play.crystal-lang.org/#/r/5avh
Only happens when having the comma on an empty array of T
The text was updated successfully, but these errors were encountered: