Crafting Interpreters 2020-08-12

By Max Woerner Chase

Now that I'm motivated to add tests to specific test modules (it's how I prefer to work, apparently), I spent some time increasing coverage, one module at a time. I got through a few modules, and then I got to the expression module, which includes stuff like dot notation, including with superclass access. Now, I guess I didn't actually write tests for this before, because when I did here, I ran into numerous issues, and the last issue I hit tonight

as I wrote the code for the book, I ran into a couple of subtle bugs where the resolver and interpreter code were slightly out of sync. Tracking those down was difficult.

... Yep. That certainly seems to be the case here, where the number of levels of parent environment is not matching.

Wow, that was arguably not actually the problem. I thought for sure I was mis-directing the layers of environments related to "this" and "super", but it turns out my implementation of method binding was, roughly speaking, dynamic instead of lexical. Which I don't know what that works out to, semantically, but it's not good.

Anyway, I'm happy I got the tests passing, but there's much more work to do. Hopefully it won't involve quite as many instances of totally untested code being howlingly wrong. I'll see about that tomorrow. For now, I should wrap up.

Good night.