Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: add sprintf helper function #75

Merged
merged 1 commit into from
Oct 31, 2024
Merged

lib: add sprintf helper function #75

merged 1 commit into from
Oct 31, 2024

Conversation

efd6
Copy link
Collaborator

@efd6 efd6 commented Oct 16, 2024

Please take a look.

@efd6 efd6 self-assigned this Oct 16, 2024
@efd6 efd6 requested a review from a team October 16, 2024 07:06
Copy link
Contributor

@kcreddy kcreddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeking a clarification. LGTM otherwise.

}
args = append(args, v)
}
return types.String(fmt.Sprintf(string(format), args...))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since in L#1095: format, ok := arg0.(types.String) we already asserted the format is a string, is it required to convert it again in L#1113?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We assert it to a types.String which is a named type with a underlying type string. We cannot use a type.String in the place of a string since although they have the same underlying type, the spec only allows assignment between different types without conversion if one of the types is not named. This is detailed in the Assignability section of the spec.

V and T have identical underlying types but are not type parameters and at least one of V or T is not a named type.

The situation in the use of the types.Int in the make call is less constrained because make's integer arguments are not specified to be int, but rather builtin.IntegerType.

@efd6 efd6 merged commit 19cb8af into dev Oct 31, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants