Skip to content

Compiler error with imported procedure with parametric polymorphism when passing it to another procedure #7331

Description

@dura4b9

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System & Odin Version:
  • Please paste odin report output:
Odin:    dev-2026-08-nightly:902106f
OS:      Windows 11 Professional (version: 23H2), build 22631.6199
CPU:     AMD Ryzen 5 5600X 6-Core Processor
RAM:     32693 MiB
Backend: LLVM 20.1.0

Expected Behavior

Program runs fine

Current Behavior

Program crashes

Failure Information (for bugs)

Steps to Reproduce

Project: bug.zip

Folder structure:
Image

package main

import "core:slice"
import "my_search_2_package"

main :: proc() {
	arr := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

	// #1 works
	for v in arr {
		_, _ = slice.binary_search(arr, v)
	}

	// #2 works
	for v in arr {
		_, _ = my_search_1(arr, v)
	}

	// #3 works
	for v in arr {
		_, _ = my_search_2_package.my_search_2(arr, v)
	}

	// #4 works
	for v in arr {
		_, _ = my_search_3(arr, v)
	}

	// #5 works, my_search_1 is inside current file
	wrapped(arr, my_search_1)

	// #6 works, my_search_3 is inside different file, but same package
	wrapped(arr, my_search_3)

	// #7 doesn't work, imported from different core package
	wrapped(arr, slice.binary_search)

	// #8 doesn't work, imported from different local package
	wrapped(arr, my_search_2_package.my_search_2)
}

wrapped :: proc(arr: []$T, search_proc: (proc(arr: []T, value: T) -> (int, bool))) {
	for v in arr {
		_, _ = search_proc(arr, v)
	}
}

my_search_1 :: proc(arr: []$T, value: T) -> (int, bool) {
	return 0, false
}

bodies of my_search_2_package.my_search_2 and my_search_3 are same as my_search_1

Now programs crashes, but if you comment case 7 wrapped(arr, slice.binary_search) and case 8 wrapped(arr, my_search_2_package.my_search_2) program will work fine

Crash only happens if we import procedure from another package and pass it to wrapped proc. If we pass procedure declared in the current file (not imported from another package) it works fine

Failure Logs

Program's output:

D:\a\Odin\Odin\src\llvm_backend_general.cpp(1419): Assertion Failure: `addr.addr.value != nullptr`
This is a compiler error. Please report this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions