This scenario has the Crystal compiler generate bad code

Depending on various tweaks, either a stack overflow or segfault occurs.

It seems to be caused by the compiler inferring types for methods combined with generic types and/or polymorphism.
This commit is contained in:
Michael Miller 2019-01-29 14:15:28 -07:00
parent 46a6a4e51e
commit 9970e2b125
2 changed files with 11 additions and 2 deletions

View File

@ -2,8 +2,9 @@ require "./expectation"
module Spectator::Expectations
# Expectation that operates on values.
# There is a primary "actual" value that the SUT produced.
# A matcher is used on that value to determine whether it satisfies some criteria.
# There are two values - the actual and expected.
# The actual value is what the SUT returned.
# The expected value is what the test wants to see.
class ValueExpectation(ActualType) < Expectation
# Creates the expectation.
# The `matched` flag should be true if the matcher is satisfied with the partial.

8
test.cr Normal file
View File

@ -0,0 +1,8 @@
require "./src/spectator"
Spectator.describe String do
let(x) { 7 }
it "a" { expect(x).to(eq(nil)) }
it "b" { expect(x.odd?).to(be_true) }
it "c" { expect(x).to(eq(42)) }
end