~mna/snow unlisted

51726a5ef2959dd97add58914fe45d829880e258 — Martin Angers 8 months ago c07fb77 + 9d3276e
Merge branch 'wip-static-func-return'
M pkg/semantic/analysis_pass.go => pkg/semantic/analysis_pass.go +10 -0
@@ 42,6 42,16 @@ func (a *analysisVisitor) Visit(n Node) Visitor {

	// ************** DECLARATIONS *****************

	case *Fn:
		// if the function has a body and does not return void, make sure
		// every branch of the function has a return or does not fallthrough
		// without returning.
		if st := AsSignatureType(n.Type()); n.Body != nil && st != nil && !IsBasicOfKind(st.Return, Void) {
			if FallsThrough(n.Body) {
				a.errh(n.Pos(), "not all branches of the function body return a value")
			}
		}

	case *Var:
		if n.Value != nil {
			aa := a.cloneRHS()

M pkg/semantic/testdata/static/fn_generic_interface.snow.err => pkg/semantic/testdata/static/fn_generic_interface.snow.err +2 -0
@@ 1,1 1,3 @@
testdata/fn_generic_interface.snow:6:6: not all branches of the function body return a value
testdata/fn_generic_interface.snow:10:6: not all branches of the function body return a value
testdata/fn_generic_interface.snow:23:14: cannot assign type struct G[bool] to variable of type interface I[int]

M pkg/semantic/testdata/static/fn_invalid_main.snow.err => pkg/semantic/testdata/static/fn_invalid_main.snow.err +1 -0
@@ 1,1 1,2 @@
testdata/fn_invalid_main.snow:1:4: main function must not have any parameter and return value, is (int) -> string
testdata/fn_invalid_main.snow:1:4: not all branches of the function body return a value

M pkg/semantic/testdata/static/fn_nested_block.snow.err => pkg/semantic/testdata/static/fn_nested_block.snow.err +1 -0
@@ 1,1 1,2 @@
main function missing
testdata/fn_nested_block.snow:1:4: not all branches of the function body return a value

M pkg/semantic/testdata/static/interface_satisfied.snow.err => pkg/semantic/testdata/static/interface_satisfied.snow.err +3 -0
@@ 1,3 1,6 @@
testdata/interface_satisfied.snow:9:6: not all branches of the function body return a value
testdata/interface_satisfied.snow:19:6: not all branches of the function body return a value
testdata/interface_satisfied.snow:23:10: not all branches of the function body return a value
testdata/interface_satisfied.snow:39:11: cannot assign type int to variable of type interface Empty
testdata/interface_satisfied.snow:42:7: cannot assign type struct S2 to variable of type interface Foo
testdata/interface_satisfied.snow:43:7: cannot assign type struct S3 to variable of type interface Foo