From ab98215fcd2f1dfdf39772f97274e0b570620544 Mon Sep 17 00:00:00 2001 From: DavePearce Date: Sat, 21 Dec 2024 21:05:02 +1300 Subject: [PATCH 1/2] Add failing test case --- pkg/test/invalid_corset_test.go | 4 ++++ testdata/basic_invalid_13.lisp | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 testdata/basic_invalid_13.lisp diff --git a/pkg/test/invalid_corset_test.go b/pkg/test/invalid_corset_test.go index ea77bbe..bc94688 100644 --- a/pkg/test/invalid_corset_test.go +++ b/pkg/test/invalid_corset_test.go @@ -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 // =================================================================== diff --git a/testdata/basic_invalid_13.lisp b/testdata/basic_invalid_13.lisp new file mode 100644 index 0000000..debe9f4 --- /dev/null +++ b/testdata/basic_invalid_13.lisp @@ -0,0 +1,7 @@ +;;error:4:22-26:unknown type +(module mmio) + +(defcolumns (COUNTER :dac)) +(defalias CT COUNTER) + +(module mmio) From 98ae0f2cc2b6e292b7477f5e20bc3f40101d3286 Mon Sep 17 00:00:00 2001 From: DavePearce Date: Sat, 21 Dec 2024 21:51:40 +1300 Subject: [PATCH 2/2] fix missing errors In a specific situation, the parser was "losing" error messages and that was causing big problems downstream. --- pkg/corset/parser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/corset/parser.go b/pkg/corset/parser.go index bff6a4b..80f9e63 100644 --- a/pkg/corset/parser.go +++ b/pkg/corset/parser.go @@ -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.