Skip to content

Commit

Permalink
Fixing Crystal 1.13 regression issues (#1900)
Browse files Browse the repository at this point in the history
* Overriding Habitat so we can test against Crystal 1.13 fixes

* fixing regression issues for Crystal 1.13. Fixes #1872

* actually use the shard override to do shard override. probably time to clean up this CI workflow
  • Loading branch information
jwoertink authored Jun 28, 2024
1 parent 4bb6543 commit 157ec4f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- shard_file: shard.edge.yml
crystal_version: latest
experimental: true
- shard_file: shard.yml
- shard_file: shard.override.yml
crystal_version: nightly
experimental: true
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions shard.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies:
habitat:
github: luckyframework/habitat
branch: main
6 changes: 4 additions & 2 deletions src/lucky/assignable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
} ||
!dec.value.is_a?(Nop)
has_explicit_value ? 1 : 0
} %}
Expand All @@ -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? %}
@{{ var.id }} : {{ type }}{% if !value.is_a?(Nop) %} = {{ value }}{% end %},
{% end %}
**unused_exposures
Expand Down
2 changes: 1 addition & 1 deletion src/lucky/routable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ module Lucky::Routable
end

{% params_with_defaults = PARAM_DECLARATIONS.select do |decl|
!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?
end %}
{% params_without_defaults = PARAM_DECLARATIONS.reject do |decl|
params_with_defaults.includes? decl
Expand Down

0 comments on commit 157ec4f

Please sign in to comment.