indutny / candor

Experimental VM for a `Candor` language
http://candor-lang.org/
177 stars 16 forks source link

Parser choking on object literal with inline function #15

Closed creationix closed 12 years ago

creationix commented 12 years ago

I tried writing an object prototype like this:


StreamPrototype = {
  pipe: (self, stream) {
    self.onData = (chunk) {
      stream:write(chunk)
    }
    self.onEnd = () {
      stream:end()
    }
  }
}

But the parser says Error on line 2: Expected string or number as object literal's key forcing me to rewrite it as:

StreamPrototype = {}
StreamPrototype.pipe = (self, stream) {
  self.onData = (chunk) {
    stream:write(chunk)
  }
  self.onEnd = () {
    stream:end()
  }
}
indutny commented 12 years ago

Thanks, fixed!