Skip to content

Commit 3392049

Browse files
committed
parser: fix missing type error is silently ignored in function return type declarations
1 parent b1314c9 commit 3392049

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

std/jule/parser/parser.jule

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,19 +722,22 @@ impl parser {
722722
}
723723

724724
fn buildMultiRetType(mut &self, mut t: &ast::RetType, mut tokens: []&token::Token, mut &i: *int): (ok: bool) {
725-
*i++
726-
if *i >= len(tokens) {
727-
*i--
725+
if *i+1 >= len(tokens) {
728726
t.Type, ok = self.buildType(tokens, i, false)
729727
ret
730728
}
731729

732-
*i-- // For point to parentheses - ( -
730+
lparen := tokens[*i]
733731
mut rangeTokens := range(i, token::LPAREN, token::RPAREN, tokens)
734732

735733
mut parts, errs := parts(rangeTokens, token::COMMA, true)
736734
self.errors = append(self.errors, errs...)
735+
// Empty range.
737736
if len(parts) == 0 {
737+
// Make sure there is no error before complain.
738+
if len(errs) == 0 {
739+
self.pushErr(lparen, "missing type")
740+
}
738741
ret
739742
}
740743

0 commit comments

Comments
 (0)