The fundamental question is whether the return type of an assignment is rhs's type or lhs's.
# B = C => ?
b = c
should a = b = c => a = c; b = c or b = c; a = b?
a = b = c
where
- a is uninferred,
- b & c have been inferred
- b's type is narrower than c's
should a's type be b's or c's?
a = b = c
where
- a is uninferred,
- b & c have been inferred
- b's type is wider than c's
should a's type be b's or c's?
def a
b = c
end
where
- a's return type is uninferred,
- b & c have been inferred
- b's type is narrower than c's
should a's return type be b's or c's?
def a
b = c
end
where
- a's return type is uninferred,
- b & c have been inferred
- b's type is wider than c's
should a's return type be b's or c's?
B < ... A C < ... < B ... < A
def a : A
b = c
end
where
- a's return type is wider than b & cs,
- a & b & c have been inferred
- b's type is wider than c's
fine
C < A < B
def a : A
b = c
end
where
- a's return type is wider than c's,
- a's return type is narrower than c's,
- a & b & c have been inferred
- b's type is wider than c's
should this be an inference error? Or should we assume a returns c?