Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Code broke without any changes


Some time over the past few days my Javascript code stopped working without making any changes to it. I’ve been using Javascript compiled locally from CoffeeScript. Now member functions show an “undefined is not a function” error when I try to call them. Accessing member variables seems to work fine, however. My code hasn’t changed in over a week and it was working fine. Now I haven’t won a single match in more than 2 days.

For example, defining

Strategy.prototype.getUnitArray = function() { … };

then later calling s.getUnitArray() gives an “undefined is not a function” error, while using


works correctly in the same place.


We had to make some changes to prevent an exploit whereby passing arguments to functions wouldn’t properly protect the APIs of those arguments. It seems like that this change broke certain member functions that it thought were part of some protected API, although I haven’t been able to figure it out quite yet. I think in this case, it’s preventing you from writing to Strategy.prototype for some reason. I’ll track the bug over here.

Here’s a workaround. Instead of using Strategy.prototype, just assign those functions in your constructor:

        this.evaluateCondition = function(nbase) { return this.evalFunc(nbase); };
        this.getUnitArray = function() { return this.units.slice(); };
        this.getMyName = function() { return this.myName; };

(By the way, is there a reason you compile with CoffeeScript and then paste into JS instead of using CodeCombat’s CoffeeScript mode?)


Thanks, I’ll give that a shot.

I’m using the compiled Javascript instead of the Coffeescript because a week or two ago there were some Aether issues that broke my Coffeescript in CC. Figured out that with a couple of changes that compiling it to Javascript myself worked.