diff --git a/compiler/fn.v b/compiler/fn.v index 0b7d8217be..acaf03d813 100644 --- a/compiler/fn.v +++ b/compiler/fn.v @@ -927,6 +927,7 @@ fn (p mut Parser) fn_call_args(f mut Fn) *Fn { } p.check(.rpar) // p.gen(')') + return f // TODO is return f right? } // "fn (int, string) int" diff --git a/compiler/parser.v b/compiler/parser.v index 6713f5b98a..c43ea31b00 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -2928,6 +2928,8 @@ fn (p mut Parser) if_st(is_expr bool, elif_depth int) string { else { typ = p.statements() } + if_returns := p.returns + p.returns = false // println('IF TYp=$typ') if p.tok == .key_else { p.fgenln('') @@ -2959,6 +2961,8 @@ fn (p mut Parser) if_st(is_expr bool, elif_depth int) string { } return typ } + else_returns := p.returns + p.returns = if_returns && else_returns p.inside_if_expr = false if p.fileis('test_test') { println('if ret typ="$typ" line=$p.scanner.line_nr') diff --git a/compiler/table.v b/compiler/table.v index 118a8bcaaf..e5dc646092 100644 --- a/compiler/table.v +++ b/compiler/table.v @@ -739,6 +739,8 @@ fn (t mut Table) fn_gen_types(fn_name string) []string { return f.types } } + panic('function $fn_name not found') // TODO panic or return []? + return []string // TODO remove return } // `foo()` diff --git a/compiler/vfmt.v b/compiler/vfmt.v index a1c7a79e53..e92dfafb8f 100644 --- a/compiler/vfmt.v +++ b/compiler/vfmt.v @@ -45,6 +45,7 @@ fn (p mut Parser) peek() Token { return tok } } + return .eof // TODO can never get here - v doesn't know that } fn (p mut Parser) fmt_inc() { diff --git a/examples/news_fetcher.v b/examples/news_fetcher.v index f2df8aea89..4b00991148 100644 --- a/examples/news_fetcher.v +++ b/examples/news_fetcher.v @@ -36,10 +36,12 @@ fn (f mut Fetcher) fetch() { resp := http.get('https://hacker-news.firebaseio.com/v0/item/${id}.json') or { println('failed to fetch data from /v0/item/${id}.json') exit(1) + return // TODO remove return } story := json.decode(Story, resp.text) or { println('failed to decode a story') exit(1) + return // TODO remove return } f.wg.done() println('#$cursor) $story.title | $story.url') diff --git a/make_tests.bat b/make_tests.bat index 06967ff71a..72b5ce3a02 100644 --- a/make_tests.bat +++ b/make_tests.bat @@ -23,6 +23,7 @@ for /r . %%x in (*_test.v) do ( v -os msvc -o test.exe -debug %%x if !ERRORLEVEL! NEQ 0 goto :fail ) + for /r . %%x in (*_test.v) do ( v.msvc.exe -os msvc -o test.exe -debug %%x if !ERRORLEVEL! NEQ 0 goto :fail diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 0141e6274e..d5a56beab4 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -462,6 +462,7 @@ pub fn (s string) count(substr string) int { i += substr.len n++ } + return 0 // TODO can never get here - v doesn't know that } pub fn (s string) contains(p string) bool { diff --git a/vlib/math/complex/complex.v b/vlib/math/complex/complex.v index b35f3c5cf4..8f38a23146 100644 --- a/vlib/math/complex/complex.v +++ b/vlib/math/complex/complex.v @@ -489,8 +489,7 @@ pub fn (c Complex) acsch() Complex { ) .divide(c) .ln() - } - if(c.re > 0) { + } else { return one.add( one.add( c.pow(2) diff --git a/vlib/math/fractions/fraction.v b/vlib/math/fractions/fraction.v index ac8a41853a..0c93881ea4 100644 --- a/vlib/math/fractions/fraction.v +++ b/vlib/math/fractions/fraction.v @@ -19,6 +19,7 @@ pub fn fraction(n i64, d i64) Fraction{ } else { panic('Denominator cannot be zero') + return Fraction{} // TODO remove return } }