pyret-lang icon indicating copy to clipboard operation
pyret-lang copied to clipboard

type error reporting in odd way

Open shriram opened this issue 1 year ago • 0 comments

Here's a full program:

fun sq(n :: Number): n * n end

modulo-power :: Number, Number, Number -> Number
fun modulo-power(base, exp, n):
  if exp == 0:
    1
  else:
    if num-round-even(exp):
      num-modulo(sq(modulo-power(base, (exp / 2), n)), n)
    else:
      num-modulo(base * modulo-power(base, (exp - 1), n), n)
    end
  end
end

The problem is num-round-even returns a number, and hence can't be used in a test position.

The type error does indeed say

image

However, note what it highlights:

image

The Boolean is actually the conditional position. Also, the then-clause has nothing to do with this.

shriram avatar Mar 27 '24 13:03 shriram