Skip to content

Commit

Permalink
fix incorrect error for invalid type (#484)
Browse files Browse the repository at this point in the history
In a specific situation, the parser was "losing" error messages and that
was causing big problems downstream.
  • Loading branch information
DavePearce authored Dec 21, 2024
1 parent 1bec69c commit 1875cc5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/corset/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ func (p *Parser) parseModuleContents(module string, terms []sexp.SExp) ([]Declar
err := p.translator.SyntaxError(s, "unexpected or malformed declaration")
errors = append(errors, *err)
} else if e.MatchSymbols(2, "module") {
return decls, terms[i:], nil
} else if decl, errs := p.parseDeclaration(module, e); errs != nil {
return decls, terms[i:], errors
} else if decl, errs := p.parseDeclaration(module, e); len(errs) > 0 {
errors = append(errors, errs...)
} else {
// Continue accumulating declarations for this module.
Expand Down
4 changes: 4 additions & 0 deletions pkg/test/invalid_corset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func Test_Invalid_Basic_12(t *testing.T) {
CheckInvalid(t, "basic_invalid_12")
}

func Test_Invalid_Basic_13(t *testing.T) {
CheckInvalid(t, "basic_invalid_13")
}

// ===================================================================
// Constant Tests
// ===================================================================
Expand Down
7 changes: 7 additions & 0 deletions testdata/basic_invalid_13.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
;;error:4:22-26:unknown type
(module mmio)

(defcolumns (COUNTER :dac))
(defalias CT COUNTER)

(module mmio)

0 comments on commit 1875cc5

Please sign in to comment.