Separating checking from execution

A language has distinct Int and Bool types and no implicit conversions. A conditional requires a Bool condition and identically typed branches. Its checker checks both branches using their types and performs no additional value analysis. At runtime, the conditional evaluates only the chosen branch.


The function divide: (Int, Int) -> Int raises a runtime error whenever its second argument is zero. Integer literals have type Int, and true and false have type Bool.


Plain text
fun safe(flag: Bool): Int =
    if flag then 8 else divide(23, 0)


Select every true statement about the definition and its calls.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Type Checking and Inference Questions: