We are designing a language that mixes typed and untyped code. We want your opinion on what should happen when untyped values flow into typed expressions.


Our language has static type checking but does not have type inference. For example, this program would pass the static type checker but would error at line 3:

var x : Number = 4;
var y = "hello";
x / y

The following 8 questions ask your opinion about possible results of running a few programs that pass the static type checker (but may still have runtime errors). We are not looking for feedback on syntax.

Question 1
var t = [4, 4];
var x : Number = t;
x

Irrespective of what you chose above, what would you think if the language generated each of the following error messages?

Question 2
var t = ["A", 3];
var nums : Array(Number) = t;
var fst1 : Number = nums[0];
fst1

Irrespective of what you chose above, what would you think if the language generated each of the following error messages?

Question 3
var obj0 = {x = "A", y = 4};
var obj1 : Object{x : Number, y : Number} = obj0;
var y : Number = obj1.y;
y

Irrespective of what you chose above, what would you think if the language generated each of the following error messages?

Question 4
var obj0 = { k = 0, add = function(i) { k = i } };
var obj1 : Object{ k : Number , add(i:String) : Void } = obj0;
obj1.add("hello");
var v : Number = obj1.k;
v

Irrespective of what you chose above, what would you think if the language generated each of the following error messages?

Question 5
var obj0 = { k = 0, add = function(i : Number) { k = i } };
var t = "hello";
obj0.add(t);
var k : String = obj0.k;
k

Irrespective of what you chose above, what would you think if the language generated each of the following error messages?

Question 6
var nums : Array(Number) = [0, 1, 2];
nums[0] = "zardoz";
nums;

Irrespective of what you chose above, what would you think if the language generated each of the following error messages?

Question 7
var x : Array(String) = ["hi", "bye"];
var y = x;
var z : Array(Number) = y;
z[0] = 42;
var a : Number = z[1];
a

Irrespective of what you chose above, what would you think if the language generated each of the following error messages?

Question 8
var obj0 = { k = 0, update = function(i : Number) { k = i } };
var obj1 = obj0;
var obj2 : Object{ k : Number, update(i : String) : Void } = obj1;
obj2.update(4);
var k : Number = obj2.k;
k

Irrespective of what you chose above, what would you think if the language generated each of the following error messages?

Followup Question
Agree/Disagree: Type annotations should not change the behavior of a program.
Background
Please answer a few questions about your background and experience.
What is your year at University?
How many years have you been programming?
If you have experience with a language that you consider typed, please select all the words that accurately complete this sentence:

"Types are useful for ___."