From 01b5d71ad04c72c17649948d441ff22f69beffea Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 21 May 2019 13:44:19 -0600 Subject: [PATCH] Fixed an issue where named subjects could crash the compiler Received: Nil assertion failed (NilAssertionError) from ??? ... Error: you've found a bug in the Crystal compiler. ... for this code: subject(point) { Point.new } describe "#x" do subject { point.x } end Redefining subjects with a named subject broke. This commit fixes that with a simply flip in the definitions. --- src/spectator/dsl/structure_dsl.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spectator/dsl/structure_dsl.cr b/src/spectator/dsl/structure_dsl.cr index f7da0e2..7f2ccaa 100644 --- a/src/spectator/dsl/structure_dsl.cr +++ b/src/spectator/dsl/structure_dsl.cr @@ -781,8 +781,8 @@ module Spectator::DSL # It is cached so that the same instance is used throughout the test. # The subject will be recreated for each test it is used in. macro subject(name, &block) - subject {{block}} - let({{name.id}}) { subject } + let({{name.id}}) {{block}} + subject { {{name.id}} } end # Defines an expression by name.