does #5174 look like something that won't take too much digging to fix? I am willing to work on and fix it because having this fixed will make a program I am working on a lot nicer to write. That said, if this would be better left to someone more familiar with that area of code, I can just wait.
Folkert probably knows best but looking at it, I dont think it would be to difficult. This kind of thing happens every so often and usually takes me <1hr
yes should be relatively easy. I'd start by looking at the mono IR that is generated
the problem is usually the mono IR, it's not an alias analysis bug
Quick IR question: is it valid to repeat an identifier in different branches in the mono ir:
if `#UserApp.32` then
let `#UserApp.9` : I64 = 3i64;
else
let `#UserApp.9` : I64 = 3i64;
Or should those be unique?
it happens a log today, so I don't think we make assumptions about it not happening
e.g. this is in our mono tests
switch Test.31:
case 0:
let Test.25 : Str = CallByName Test.9 Test.23;
jump Test.24 Test.25;
default:
let Test.25 : Str = CallByName Test.11 Test.23;
jump Test.24 Test.25;
:thumbs_up:
The issue seems to be caused by this line being repeated in both branches of an if/else:
let `#UserApp.8` : Int1 = CallByName `Num.isLt` `#UserApp.x` `#UserApp.9`;
Given it has the exact same arg names and function, I think they are getting the same specialization id.
Though that doesn't exactly explain the bug to me. What is wrong with two calls having the same CalleeSpecVar
? Does that just mean that both functions use the same specialized version of a function? I assume I don't quite understand what the CalleeSpecVar
means.
multiple calls might end up resolving to the same specialization, but I believe each call must be annotated with a unique variable because morphic might or might not assign them unique specializations
by the way, ROC_CHECK_MONO_IR=1
should catch this if that is indeed the problem
because we should create a unique CallSpecId in mono
for each call
yeah, it finds issues:
IR PROBLEMS FOUND:
── DUPLICATE JOIN POINT ────────────────────────────────────────────────────────
in main : () -> {Str, {}} ((niche {}))
18│ let `#UserApp.x` : I64 = lowlevel ListGetUnsafe `#UserApp.data` `#UserApp.15`;
19│> joinpoint `#UserApp.7` `#UserApp.14`:
20│ if `#UserApp.14` then
The join point #UserApp.7 was previously defined here
48│ let `#UserApp.28` : U64 = 1i64;
49│> let `#UserApp.29` : Int1 = lowlevel NumGte `#UserApp.27` `#UserApp.28`;
50│ if `#UserApp.29` then
and is redefined here
── DUPLICATE CALL SPEC ID ──────────────────────────────────────────────────────
in main : () -> {Str, {}} ((niche {}))
24│ in
25│> let `#UserApp.9` : I64 = 3i64;
26│ let `#UserApp.8` : Int1 = CallByName `Num.isLt` `#UserApp.x` `#UserApp.9`;
This call has a specialization ID
54│ if `#UserApp.25` then
55│> jump `#UserApp.12`;
56│ else
...that is the same as the specialization ID of the call here
Last updated: Jul 05 2025 at 12:14 UTC