Thanks to visit codestin.com
Credit goes to github.com

Skip to content

linker error when enum with a lambda associcated value used as the key in a hashmap #2428

@Book-reader

Description

@Book-reader
import std::collections::map;

enum TestEnum : char (SomethingFn f)
{
	FOO = fn () {}
}
fn uint TestEnum.hash(self) => self.ordinal.hash();

alias SomethingFn = fn void();


fn int main(String[] args)
{
	HashMap {TestEnum, int} a;
	return 0;
}
/nix/store/v63bxfiacw082c7ijshf60alvvrpfxsq-binutils-2.44/bin/ld: /tmp/nix-shell.MxB3nc/nix-shell.awMUlW/c3cXJB1jUr/obj/linux-x64/std_collections_map.test.TestEnum.int.o:(.data.rel.ro.test.TestEnum$f[test.TestEnum$f]+0x0): undefined reference to `test.$global$lambda1'

this doesn't happen at optimisation levels higher than -O0

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingFixed needs testingNeeds verification / testing that it now works

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions