Questions: Gradual Typing and Mixed Static-Dynamic Types

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A variable typed as `any` holds a string value. It is then passed to a function with the signature f(x: int) -> string. When does the type error surface?

AAt compile time — the type checker detects the incompatibility when the function is called
BNever — the `any` type is compatible with everything, so no error can occur
CAt runtime — the compiler inserts a cast that checks whether the value is actually an int when it enters the statically typed context
DAt compile time only if the function was written in the same module as the caller
Question 2 Multiple Choice

How does the 'consistency' relation in gradual typing differ from conventional subtyping?

AConsistency requires exact type equality; subtyping allows structural compatibility
BConsistency allows `any` to match any type as a wildcard, while subtyping requires a declared hierarchical relationship between concrete types
CSubtyping is checked at runtime while consistency is checked at compile time
DConsistency is strictly weaker — it allows all the same type assignments as subtyping plus more
Question 3 True / False

In a gradual type system, passing an `any` value into a statically typed function parameter requires a runtime type check inserted by the compiler at the boundary between typed and untyped code.

TTrue
FFalse
Question 4 True / False

Gradual typing eliminates type errors in partially-typed code because the `any` type is compatible with everything — code that uses `any` cannot fail due to type mismatches.

TTrue
FFalse
Question 5 Short Answer

What is the 'blame problem' in gradual typing, and why does it matter in large codebases that mix typed and untyped code?

Think about your answer, then reveal below.