-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Fixing Crystal 1.13 regression issues #1900
Conversation
@@ -89,7 +89,9 @@ module Lucky::Assignable | |||
{% sorted_assigns = ASSIGNS.sort_by { |dec| | |||
has_explicit_value = | |||
dec.type.is_a?(Metaclass) || | |||
dec.type.types.map(&.id).includes?(Nil.id) || | |||
dec.type.types.any? { |t| | |||
(t.is_a?(Metaclass) || t.is_a?(ProcNotation) || t.is_a?(Generic)) ? false : t.names.includes?(Nil.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of doing this, but if we use type.resolve
here we will have to force all Lucky apps to start adding a bunch of require
statements at the top of all the files because of examples like..
class PostPage < MainLayout
# in macro land, Crystal doesn't know what "User" is yet. If we resolve this type at compile time, we will have to require it at the top of this file.
needs user : User
# ...
end
This starts to compound when you're talking about hundreds of actions, models, queries, operations, pages, etc...
@@ -98,7 +100,7 @@ module Lucky::Assignable | |||
{% var = declaration.var %} | |||
{% type = declaration.type %} | |||
{% value = declaration.value %} | |||
{% value = nil if type.stringify.ends_with?("Nil") && !value %} | |||
{% value = nil if type.stringify.ends_with?("Nil") && value.nil? %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this because if for some reason you did param thingable : Bool? = false
it would default the value to nil
. Probably a non-issue, but why not? 🤷♂️
!decl.value.is_a?(Nop) || decl.type.is_a?(Union) && decl.type.types.last.id == Nil.id | ||
!decl.value.is_a?(Nop) || decl.type.is_a?(Union) && decl.type.resolve.nilable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here resolve.nilable?
should be ok 🤞 .... but if it starts blowing up apps, then we know where to come back to..
…o clean up this CI workflow
Purpose
Fixes #1872
Description
Crystal 1.13 changes how
Nil
is written on the macro side. This broke some of the Lucky code because now::Nil.id
is not the same asNil.id
.Checklist
crystal tool format spec src
./script/setup
./script/test