Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,17 @@ func TestEval_exposed_error(t *testing.T) {
require.Equal(t, 1, fileError.Line)
}

func TestCompile_exposed_error_with_multiline_script(t *testing.T) {
_, err := expr.Compile("{\n\ta: 1,\n\tb: #,\n\tc: 3,\n}")
require.Error(t, err)

fileError, ok := err.(*file.Error)
require.True(t, ok, "error should be of type *file.Error")
require.Equal(t, "unexpected token Operator(\"#\") (3:5)\n | b: #,\n | ....^", fileError.Error())
require.Equal(t, 4, fileError.Column)
require.Equal(t, 3, fileError.Line)
}

func TestIssue105(t *testing.T) {
type A struct {
Field string
Expand Down
5 changes: 3 additions & 2 deletions file/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ func (e *Error) Bind(source Source) *Error {
break
}
if r == '\n' {
lineStart = i
lineStart = i + 1
e.Line++
e.Column = 0
} else {
e.Column++
}
runeCount++
e.Column++
}

lineEnd := lineStart + strings.IndexByte(src[lineStart:], '\n')
Expand Down
Loading