# \#pg8 (Functions without arguments): Add check for redefining clock()?

**URL:** <https://forum.codecrafters.io/t/pg8-functions-without-arguments-add-check-for-redefining-clock/16044>\
**Category:** Feature Requests\
**Tags:** challenge:interpreter\
**Created:** [April 11, 2026, 3:13am UTC](https://forum.codecrafters.io/t/pg8-functions-without-arguments-add-check-for-redefining-clock/16044 "2026-04-11T03:13:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yinchi](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/yinchi/32/23920_2.png) [@yinchi](https://forum.codecrafters.io/u/yinchi)\
**Post date:** [April 11, 2026, 3:13am UTC](https://forum.codecrafters.io/t/pg8-functions-without-arguments-add-check-for-redefining-clock/16044/1 "2026-04-11T03:13:22Z")

</div>

I was wondering about the correct behavior for code like:

```auto
print clock();
fun clock() {
  return 0;
}
print clock();

```

I think that we need to allow `clock` to be shadowed by the new definition. This means that the root program environment needs to be populated with our builtins, rather than using a separate lookup table (which would prevent shadowing). I had made this mistake previously, however there doesn’t seem to be a test for it.

There might also be a test to see whether the “evaluate” function from before can also handle builtins, not just “run”.

---

<div class="post-metadata">

**Author:** ![yinchi](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/yinchi/32/23920_2.png) [@yinchi](https://forum.codecrafters.io/u/yinchi)\
**Post date:** [April 11, 2026, 10:36pm UTC](https://forum.codecrafters.io/t/pg8-functions-without-arguments-add-check-for-redefining-clock/16044/4 "2026-04-11T22:36:46Z")

</div>

Another weird test that’s especially relevant to the Rust path:

```auto
fun foo() {}
print foo == foo;

```

Thus the AST nodes representing `foo` must hold an `Rc` to the same data, and cloning that data during node creation would be an error (returns `false` for the above test instead of `true`).

---

<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:** [April 14, 2026, 1:43am UTC](https://forum.codecrafters.io/t/pg8-functions-without-arguments-add-check-for-redefining-clock/16044/5 "2026-04-14T01:43:26Z")

</div>

Hey @yinchi, since you’ve finished the Resolving and Binding extension, does Stage #PZ7 (Variable Redeclaration) cover the problematic case you’ve encountered?

---

<div class="post-metadata">

**Author:** ![yinchi](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/yinchi/32/23920_2.png) [@yinchi](https://forum.codecrafters.io/u/yinchi)\
**Post date:** [April 14, 2026, 2:38am UTC](https://forum.codecrafters.io/t/pg8-functions-without-arguments-add-check-for-redefining-clock/16044/7 "2026-04-14T02:38:18Z")

</div>

I think the issue here is realizing that builtin functions need to be treated like any other type of variable, thus allowing them to be redefined. I made a mistake of treating `clock` like a keyword and bypassing normal variable lookup. I learned I definitely need to pay more attention to what the book says.

#PZ7 comes before the functions portion of the challenge so the tests won’t cover this case. The second example I gave, checking that a function is equal to itself, is also not tested for as far as I know.
