From beff08417b04a91f0a7618b55786d63eec833b9f Mon Sep 17 00:00:00 2001 From: Tony Ghita Date: Wed, 11 Oct 2017 10:48:39 -0700 Subject: [PATCH] Separate literal arg parsing cases (int, float) This change allows the ID scalar implementation to more semantically handle the case for unmarshalling integer IDs. --- internal/common/literals.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/common/literals.go b/internal/common/literals.go index 6251e50476d..d1c84e3ac57 100644 --- a/internal/common/literals.go +++ b/internal/common/literals.go @@ -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)