Skip to content

Commit b81e414

Browse files
committedJan 24, 2025·
lint
1 parent 5c2e54c commit b81e414

File tree

8 files changed

+337
-366
lines changed

8 files changed

+337
-366
lines changed
 

‎interpreter/dynamic_casting_test.go

+29-30
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,11 @@ func returnResourceCasted(fromType, targetType string, operation ast.Operation)
737737

738738
func testResourceCastValid(t *testing.T, types, fromType string, targetType string, operation ast.Operation) {
739739
inter := parseCheckAndInterpret(t,
740-
types+
741-
returnResourceCasted(
742-
fromType,
743-
targetType,
744-
operation,
745-
),
740+
types+returnResourceCasted(
741+
fromType,
742+
targetType,
743+
operation,
744+
),
746745
)
747746

748747
value, err := inter.Invoke("test")
@@ -776,12 +775,10 @@ func testResourceCastValid(t *testing.T, types, fromType string, targetType stri
776775

777776
func testResourceCastInvalid(t *testing.T, types, fromType, targetType string, operation ast.Operation) {
778777
inter := parseCheckAndInterpret(t,
779-
fmt.Sprintf(
780-
types+returnResourceCasted(
781-
fromType,
782-
targetType,
783-
operation,
784-
),
778+
types+returnResourceCasted(
779+
fromType,
780+
targetType,
781+
operation,
785782
),
786783
)
787784

@@ -886,12 +883,11 @@ func returnStructCasted(fromType, targetType string, operation ast.Operation) st
886883

887884
func testStructCastValid(t *testing.T, types, fromType string, targetType string, operation ast.Operation) {
888885
inter := parseCheckAndInterpret(t,
889-
types+
890-
returnStructCasted(
891-
fromType,
892-
targetType,
893-
operation,
894-
),
886+
types+returnStructCasted(
887+
fromType,
888+
targetType,
889+
operation,
890+
),
895891
)
896892

897893
value, err := inter.Invoke("test")
@@ -925,13 +921,10 @@ func testStructCastValid(t *testing.T, types, fromType string, targetType string
925921

926922
func testStructCastInvalid(t *testing.T, types, fromType, targetType string, operation ast.Operation) {
927923
inter := parseCheckAndInterpret(t,
928-
fmt.Sprintf(
929-
types+
930-
returnStructCasted(
931-
fromType,
932-
targetType,
933-
operation,
934-
),
924+
types+returnStructCasted(
925+
fromType,
926+
targetType,
927+
operation,
935928
),
936929
)
937930

@@ -2256,8 +2249,12 @@ func returnReferenceCasted(fromType, targetType string, operation ast.Operation,
22562249

22572250
func testReferenceCastValid(t *testing.T, types, fromType, targetType string, operation ast.Operation, isResource bool) {
22582251
inter := parseCheckAndInterpret(t,
2259-
types+
2260-
returnReferenceCasted(fromType, targetType, operation, isResource),
2252+
types+returnReferenceCasted(
2253+
fromType,
2254+
targetType,
2255+
operation,
2256+
isResource,
2257+
),
22612258
)
22622259

22632260
value, err := inter.Invoke("test")
@@ -2309,9 +2306,11 @@ func testReferenceCastValid(t *testing.T, types, fromType, targetType string, op
23092306

23102307
func testReferenceCastInvalid(t *testing.T, types, fromType, targetType string, operation ast.Operation, isResource bool) {
23112308
inter := parseCheckAndInterpret(t,
2312-
fmt.Sprintf(
2313-
types+
2314-
returnReferenceCasted(fromType, targetType, operation, isResource),
2309+
types+returnReferenceCasted(
2310+
fromType,
2311+
targetType,
2312+
operation,
2313+
isResource,
23152314
),
23162315
)
23172316

‎old_parser/declaration.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,10 @@ func parseHexadecimalLocation(p *parser) common.AddressLocation {
747747
address, err := common.BytesToAddress(rawAddress)
748748
if err != nil {
749749
// Any returned error is a syntax error. e.g: Address too large error.
750-
p.reportSyntaxError(err.Error())
750+
p.report(&SyntaxError{
751+
Pos: p.current.StartPos,
752+
Message: err.Error(),
753+
})
751754
}
752755

753756
return common.NewAddressLocation(p.memoryGauge, address, "")

‎old_parser/parser.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ func (p *parser) next() {
243243
}
244244
parseError, ok := err.(ParseError)
245245
if !ok {
246-
parseError = NewSyntaxError(
247-
token.StartPos,
248-
err.Error(),
249-
)
246+
parseError = &SyntaxError{
247+
Pos: token.StartPos,
248+
Message: err.Error(),
249+
}
250250
}
251251
p.report(parseError)
252252
continue

‎parser/declaration.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,10 @@ func parseHexadecimalLocation(p *parser) common.AddressLocation {
910910
address, err := common.BytesToAddress(rawAddress)
911911
if err != nil {
912912
// Any returned error is a syntax error. e.g: Address too large error.
913-
p.reportSyntaxError(err.Error())
913+
p.report(&SyntaxError{
914+
Pos: p.current.StartPos,
915+
Message: err.Error(),
916+
})
914917
}
915918

916919
return common.NewAddressLocation(p.memoryGauge, address, "")

‎parser/parser.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ func (p *parser) next() {
260260
}
261261
parseError, ok := err.(ParseError)
262262
if !ok {
263-
parseError = NewSyntaxError(
264-
token.StartPos,
265-
err.Error(),
266-
)
263+
parseError = &SyntaxError{
264+
Pos: token.StartPos,
265+
Message: err.Error(),
266+
}
267267
}
268268
p.report(parseError)
269269
continue

0 commit comments

Comments
 (0)