disco-lang / disco

Functional teaching language for use in a discrete mathematics course
Other
162 stars 23 forks source link

Zn or rational exponents cause crash #92

Closed byorgey closed 6 years ago

byorgey commented 6 years ago
Disco> 3 ^ (5 : Z7)
Impossible! getType at2 is not num type after checkNumTy
CallStack (from HasCallStack):
  error, called at src/Disco/Typecheck.hs:689:12 in disco-0.1.0.0-3EaSG6nlUNwHFiM37sO460:Disco.Typecheck

Off the top of my head I'm not sure whether this should be allowed or a type error; but in any case it shouldn't crash.

It turns out this crashes too:

Disco> 5^(1/2)
Impossible! getType at2 is not num type after checkNumTy
CallStack (from HasCallStack):
  error, called at src/Disco/Typecheck.hs:689:12 in disco-0.1.0.0-3EaSG6nlUNwHFiM37sO460:Disco.Typecheck

This should definitely be a type error (because fractional exponents might not result in a rational result), but it shouldn't cause the typechecker to crash.

byorgey commented 6 years ago

This is fixed in the poly-types branch.