hylo-lang / hylo

The Hylo programming language
https://www.hylo-lang.org
Apache License 2.0
1.24k stars 58 forks source link

Avoid monomorphizing non-generic functions #1052

Closed kyouko-taiga closed 10 months ago

kyouko-taiga commented 1 year ago

Int.copy gets monomorphized in the following program:

public fun main() {
  _ = Array<Int>()
}

Monomorphization occurs in Array.count with the expression storage.header.copy(). I suspect that name resolution is attaching to copy the generic parameters accumulated by storage.header.

One solution to fix this problem might be to only attach generic arguments of the referred declaration in TypedProgram.referredDecl (as opposed to accumulated generic arguments) and to re-construct the full list during monomorphization. In the above example, it would mean that copy would get associated with any generic argument in TypedProgram.referredDecl.

kyouko-taiga commented 10 months ago

Fixed by #1157