diff --git a/error.go b/error.go index 80b6d05..e7ee9b5 100644 --- a/error.go +++ b/error.go @@ -224,7 +224,7 @@ func parseSyntaxError(errorText string) (string, int) { parts := strings.Split(errorText, " near ") if len(parts) == 2 { - text = strings.TrimSuffix(parts[1], "\n") + text = strings.Join(strings.Fields(strings.TrimSuffix(parts[1], "\n")), " ") where := strings.Split(strings.TrimSuffix(strings.ReplaceAll(parts[0], " line:", ""), ")"), "(column:") if v, err := strconv.Atoi(where[0]); err == nil { problem = v diff --git a/error_test.go b/error_test.go index aeb921f..0535a74 100644 --- a/error_test.go +++ b/error_test.go @@ -15,22 +15,22 @@ func TestErrorSourceSyntaxError(t *testing.T) { { name: "Inline", src: "local p = person.new('Steeve');lokal t = 'fail'", - expected: "Line 1: 't': parse error", + expected: "Line 1: 't': parse error", }, { name: "Parsing error", src: "local p = person.new('Steeve')\nlokal t = 'fail'", - expected: "Line 2: 't': parse error", + expected: "Line 2: 't': parse error", }, { name: "Bad token", src: "local p = person.new('Steeve')\nlocal t & 'fail'", - expected: "Line 2: '&': Invalid token", + expected: "Line 2: '&': Invalid token", }, { name: "Unterminated string", src: "local p = person.new('Steeve)\nlocal t = 'okay'", - expected: "Line 2: 'Steeve)': unterminated string", + expected: "Line 2: 'Steeve)': unterminated string", }, { name: "End of file",