Skip to content

basicLit: format numbers from the reflect.Value's kind#28

Open
c-tonneslan wants to merge 1 commit into
hexops:mainfrom
c-tonneslan:fix/basiclit-uses-stringer-for-numbers
Open

basicLit: format numbers from the reflect.Value's kind#28
c-tonneslan wants to merge 1 commit into
hexops:mainfrom
c-tonneslan:fix/basiclit-uses-stringer-for-numbers

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #11.

fmt.Sprint(v) on a named numeric type like time.Duration calls the type's Stringer ("1h0m0s"), so the produced AST contained an invalid Go literal and gofumpt then errored with "missing ',' in argument list". Format INT / FLOAT / UINT from the reflect.Value's kind so the literal is always valid Go syntax.

Closes hexops#11.

fmt.Sprint(v) on a named numeric type like time.Duration calls the
type's Stringer (returns '1h0m0s'), so the produced AST contained an
invalid Go literal and gofumpt then errored with 'missing ',' in
argument list'. Format INT/FLOAT/UINT from the reflect.Value's kind
so the literal is always valid Go syntax.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Can not show time.Duration

1 participant