Skip to content

Commit

Permalink
Separate literal arg parsing cases (int, float)
Browse files Browse the repository at this point in the history
This change allows the ID scalar implementation to more semantically
handle the case for unmarshalling integer IDs.
  • Loading branch information
tonyghita authored and neelance committed Oct 14, 2017
1 parent ab1dd4b commit beff084
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/common/literals.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ type BasicLit struct {

func (lit *BasicLit) Value(vars map[string]interface{}) interface{} {
switch lit.Type {
case scanner.Int, scanner.Float:
case scanner.Int:
value, err := strconv.ParseInt(lit.Text, 10, 32)
if err != nil {
panic(err)
}
return int32(value)

case scanner.Float:
value, err := strconv.ParseFloat(lit.Text, 64)
if err != nil {
panic(err)
Expand Down

0 comments on commit beff084

Please sign in to comment.