Skip to content

Commit 157ec4f

Browse files
authored
Fixing Crystal 1.13 regression issues (#1900)
* 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
1 parent 4bb6543 commit 157ec4f

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- shard_file: shard.edge.yml
4141
crystal_version: latest
4242
experimental: true
43-
- shard_file: shard.yml
43+
- shard_file: shard.override.yml
4444
crystal_version: nightly
4545
experimental: true
4646
runs-on: ubuntu-latest

shard.override.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies:
2+
habitat:
3+
github: luckyframework/habitat
4+
branch: main

src/lucky/assignable.cr

+4-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ module Lucky::Assignable
8989
{% sorted_assigns = ASSIGNS.sort_by { |dec|
9090
has_explicit_value =
9191
dec.type.is_a?(Metaclass) ||
92-
dec.type.types.map(&.id).includes?(Nil.id) ||
92+
dec.type.types.any? { |t|
93+
(t.is_a?(Metaclass) || t.is_a?(ProcNotation) || t.is_a?(Generic)) ? false : t.names.includes?(Nil.id)
94+
} ||
9395
!dec.value.is_a?(Nop)
9496
has_explicit_value ? 1 : 0
9597
} %}
@@ -98,7 +100,7 @@ module Lucky::Assignable
98100
{% var = declaration.var %}
99101
{% type = declaration.type %}
100102
{% value = declaration.value %}
101-
{% value = nil if type.stringify.ends_with?("Nil") && !value %}
103+
{% value = nil if type.stringify.ends_with?("Nil") && value.nil? %}
102104
@{{ var.id }} : {{ type }}{% if !value.is_a?(Nop) %} = {{ value }}{% end %},
103105
{% end %}
104106
**unused_exposures

src/lucky/routable.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ module Lucky::Routable
260260
end
261261

262262
{% params_with_defaults = PARAM_DECLARATIONS.select do |decl|
263-
!decl.value.is_a?(Nop) || decl.type.is_a?(Union) && decl.type.types.last.id == Nil.id
263+
!decl.value.is_a?(Nop) || decl.type.is_a?(Union) && decl.type.resolve.nilable?
264264
end %}
265265
{% params_without_defaults = PARAM_DECLARATIONS.reject do |decl|
266266
params_with_defaults.includes? decl

0 commit comments

Comments
 (0)