I think I must not be understanding how overloads are resolved in class methods

The compile error seems to be clearly saying that there is no overload that matches, despite the second overload clearly does. I must not be understanding something here.

I believe it’s relevant that I’m calling Item.new from inside the class (from a self.import class method). Before I refactored the code to move the import inside the class, it was able to resolve the overload.

 211 | hash[name] = Item.new(name, itype, slot, id)
                                          ^---
Error: expected argument 3 to 'Item.new' to be (Slot | Nil), not (String | Nil)

Overloads are:
 - Item.new(name : String, itype : ItemType, slot : Slot | Nil, id : String | Nil)
 - Item.new(name : String, itype : ItemType, slot : String | Nil, id : String | Nil)

Can you share some example code that reproduces this?

I tried to create a minimal example… but it successfully resolved the overload without error. Let me see what else I can do. It’s not large, or private, but it is multiple files.

2 Likes