# \#DG2 test case 3 should not be a compilation error but runtime error

**URL:** <https://forum.codecrafters.io/t/dg2-test-case-3-should-not-be-a-compilation-error-but-runtime-error/13813>\
**Category:** Bug Reports\
**Tags:** challenge:interpreter\
**Created:** [July 21, 2025, 9:32am UTC](https://forum.codecrafters.io/t/dg2-test-case-3-should-not-be-a-compilation-error-but-runtime-error/13813 "2025-07-21T09:32:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arichy](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/arichy/32/13805_2.png) [@Arichy](https://forum.codecrafters.io/u/Arichy)\
**Post date:** [July 21, 2025, 9:32am UTC](https://forum.codecrafters.io/t/dg2-test-case-3-should-not-be-a-compilation-error-but-runtime-error/13813/1 "2025-07-21T09:32:52Z")

</div>

![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/3/370dddfbe124219751ee0a6d8d65c51de2fccab0.png)

Tested in lox playground, for the test case 3, if the `m(instance)` call is commented out:

```auto
class Confused {
  method() {
    fun inner(instance) {
      var feeling = "confused";
      print this.feeling;
    }
    return inner;
  }
}

var instance = Confused();
var m = instance.method();
// m(instance);

```

lox will not throw an error and run successfully.

If we add a print before `m(instance)`:

```auto
class Confused {
  method() {
    fun inner(instance) {
      var feeling = "confused";
      print this.feeling;
    }
    return inner;
  }
}

var instance = Confused();
var m = instance.method();
print 123;
m(instance);

```

lox would parse it successfully and run it as well, and `123` would **print in console, not shown in the page.**

So it should be a runtime error instead of compilation error. And it’s not a good idea to track binding properties on an object during parse stage of a dynamic language.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [July 21, 2025, 11:00am UTC](https://forum.codecrafters.io/t/dg2-test-case-3-should-not-be-a-compilation-error-but-runtime-error/13813/3 "2025-07-21T11:00:26Z")

</div>

Hey @Arichy, thanks for highlighting the issue! I’ll check with the team and get back to you once we’ve identified the best approach to a fix.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [July 21, 2025, 4:42pm UTC](https://forum.codecrafters.io/t/dg2-test-case-3-should-not-be-a-compilation-error-but-runtime-error/13813/5 "2025-07-21T16:42:29Z")

</div>

Sorry for the confusion! The [tester’s behavior](https://github.com/codecrafters-io/interpreter-tester/blob/main/test_programs/cl6/4.lox) is actually correct.

The issue was with the instructions, which are addressed in [this PR](https://github.com/codecrafters-io/build-your-own-interpreter/pull/118#pullrequestreview-3038893835).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [July 29, 2025, 4:59am UTC](https://forum.codecrafters.io/t/dg2-test-case-3-should-not-be-a-compilation-error-but-runtime-error/13813/7 "2025-07-29T04:59:28Z")

</div>

Closed on July 29, 2025, 4:59am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
