Laythe-lang / Laythe

A gradually typed language originally based on the crafting interpreters series
MIT License
65 stars 4 forks source link

Fix native subclassing #138

Closed jonnyboyC closed 1 year ago

jonnyboyC commented 1 year ago

Problem

Today we can't really subclass a native generated class. These problems are seen when we subclass a user generated class. Overall there were two problems

  1. Adding a field assumed that something else did a dedup and we would always insert a new value
  2. We didn't keep the same field order for the subclass as parent class. This likely wasn't a problem because we would cache miss the inline cache then do a lookup again

Solution

Now we don't make the assumption on fields and we keep the same field order as our parent class.