Skip to content

Monomorphization: type inference misses ArrayLit and FnCall argument types #318

@aallan

Description

@aallan

Bug

_get_arg_type_info in monomorphize.py only handles SlotRef and ConstructorCall expressions. When a generic function is called with an array literal ([1, 2, 3]) or the result of another function call (array_range(0, 5)), type variable inference fails and defaults to Bool (phantom fallback).

Example

array_map([1, 2, 3], fn(@Int -> @Int) effects(pure) { @Int.0 * 2 })

The first argument [1, 2, 3] is an ArrayLit. _get_arg_type_info returns None for it, so A defaults to Bool instead of Int, producing array_map$Bool_Bool instead of array_map$Int_Int.

Impact

Calling generic functions with array literal or function call arguments produces incorrect monomorphization — wrong types, potential runtime crashes.

Fix

Added ArrayLit and FnCall cases to _get_arg_type_info. ArrayLit infers element type from first element; FnCall handles known return types like array_rangeArray<Int>. Fixed in the feat/array-operations branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions