Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type error reporting in odd way #1730

Open
shriram opened this issue Mar 27, 2024 · 0 comments
Open

type error reporting in odd way #1730

shriram opened this issue Mar 27, 2024 · 0 comments

Comments

@shriram
Copy link
Member

shriram commented Mar 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant