Skip to content

Commit

Permalink
fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
douyixuan committed Sep 18, 2024
1 parent 09a37d9 commit 4e293ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 8 additions & 1 deletion compiler/compiler/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ func (c *Compiler) compileConstantNode(v *parser.ConstantNode) value.Value {
IsVariable: false,
}
case parser.NUMBER:
var intType *types.Int = i64
// To make primitive have method table, there is a hacking way:
// by defining the type with the same name: `type uint64 uint64`,
// then new methods can be added to primitive types.
// Here we try to simulate the hacking approach.
// The default number type is uint64.
var intType *types.Int = c.parserTypeToType(&parser.SingleTypeNode{
SourceName: "uint64", TypeName: "uint64",
}).(*types.Int)

if v.TargetType != nil {
intType = c.parserTypeToType(v.TargetType).(*types.Int)
Expand Down
2 changes: 0 additions & 2 deletions compiler/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ func (p *parser) parseNumberSuffix() (ty TypeNode) {
ty = &SingleTypeNode{SourceName: "uint256", TypeName: "uint256"}
p.i++
}
} else {
ty = &SingleTypeNode{SourceName: "uint64", TypeName: "uint64"}
}
return
}
Expand Down

0 comments on commit 4e293ad

Please sign in to comment.