diff --git a/rewriter/Minitest.cc b/rewriter/Minitest.cc index 0a4b1b04c..5806ab71c 100644 --- a/rewriter/Minitest.cc +++ b/rewriter/Minitest.cc @@ -225,14 +225,14 @@ ast::ExpressionPtr runUnderEach(core::MutableContext ctx, core::NameRef eachName ((send->fun == core::Names::before() || send->fun == core::Names::after()) && send->numPosArgs() == 0 && correctBlockArity)) { core::NameRef name; - auto arg0Loc = core::LocOffsets::none(); + auto nameLoc = send->funLoc; if (send->fun == core::Names::before()) { name = core::Names::beforeAngles(); } else if (send->fun == core::Names::after()) { name = core::Names::afterAngles(); } else { // we use this for the name of our test - arg0Loc = send->getPosArg(0).loc(); + nameLoc = send->getPosArg(0).loc(); auto argString = to_s(ctx, send->getPosArg(0)); name = ctx.state.enterNameUTF8(""); } @@ -266,7 +266,7 @@ ast::ExpressionPtr runUnderEach(core::MutableContext ctx, core::NameRef eachName send->loc.copyWithZeroLength(), move(blk)); // put that into a method def named the appropriate thing auto declLoc = declLocForSendWithBlock(*send); - auto method = addSigVoid(ast::MK::SyntheticMethod0(send->loc, declLoc, arg0Loc, move(name), move(each))); + auto method = addSigVoid(ast::MK::SyntheticMethod0(send->loc, declLoc, nameLoc, move(name), move(each))); // add back any moved constants return constantMover.addConstantsToExpression(send->loc, move(method)); } else if (send->fun == core::Names::describe() && send->numPosArgs() == 1 && correctBlockArity) { diff --git a/test/scip/testdata/minitest_3.rb b/test/scip/testdata/minitest_3.rb index cd009cd97..c8445ac80 100644 --- a/test/scip/testdata/minitest_3.rb +++ b/test/scip/testdata/minitest_3.rb @@ -11,6 +11,10 @@ def self.describe(name, &blk); end test_each([[1,2], [3,4]]) do |(a,b)| describe "d" do + before do + end + after do + end it "b" do T.reveal_type(a) # error: Revealed type: `Integer` end diff --git a/test/scip/testdata/minitest_3.snapshot.rb b/test/scip/testdata/minitest_3.snapshot.rb index a26e444ba..e98d7da76 100644 --- a/test/scip/testdata/minitest_3.snapshot.rb +++ b/test/scip/testdata/minitest_3.snapshot.rb @@ -31,6 +31,16 @@ def self.describe(name, &blk); end # ^ definition local 2$416088458 describe "d" do +# ⌄ enclosing_range_start [..] Test#``(). + before do +# ^^^^^^ definition [..] Test#``(). + end +# ⌃ enclosing_range_end [..] Test#``(). +# ⌄ enclosing_range_start [..] Test#``(). + after do +# ^^^^^ definition [..] Test#``(). + end +# ⌃ enclosing_range_end [..] Test#``(). # ⌄ enclosing_range_start [..] Test#``(). it "b" do # ^^^ definition [..] Test#``().