Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit df860e0

Browse files
committed
Print lines on type exception
1 parent 2f10f6d commit df860e0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ function parseDeclaration(): SyntaxTree {
159159
/* Assign operator */
160160
if (getToken(currentIndex + 4).lexeme == PUNCTUATION['EQUALS']) {
161161
if (getToken(currentIndex + 6).lexeme == PUNCTUATION['DOT']) {
162-
throw `Number type must be an integer.`
162+
throw `Number type must be an integer at ${getLocation(getToken(currentIndex + 5))}`
163163
}
164164
action = DECLARE_ASSIGN
165165
valueToken = getToken(currentIndex + 5)
166166
if (type.name.toString().toLowerCase() != valueToken.name.toString().toLowerCase()) {
167-
throw `${valueToken.name} cannot be assigned to ${type.name}`
167+
throw `${valueToken.name} cannot be assigned to ${type.name} at ${getLocation(getToken(currentIndex + 4))}`
168168
}
169169
value = createConstant(valueToken)
170170
skipAhead = 6

0 commit comments

Comments
 (0)