jasmin icon indicating copy to clipboard operation
jasmin copied to clipboard

The storage modifier of the return type of a function is ignored

Open eponier opened this issue 4 years ago • 2 comments

If we compile the following function in the glob_array3 branch

 inline fn sum (stack u64[2] a) -> stack u64 {
  reg u64 r;
  
  r = a[0];
  r += a[1];
    
  return r;
}

the stack storage in the type is simply ignored and replace by reg. If we replace stack with either reg ptr or stack ptr, we get the same result. This is a bit confusing.

Maybe this is done on purpose to have a uniform syntax, and it is known that the storage modifier in the return type of a function is ignored and instead inferred from the body of the function, in which case this issue can be marked as invalid, but I prefer to ask.

eponier avatar Mar 17 '21 17:03 eponier

Benjamin's remark: we should update the type checker!

eponier avatar Mar 18 '21 14:03 eponier

Yes, the type checker should enforce that the given signature is correct.

vbgl avatar Mar 19 '21 09:03 vbgl