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

Return a transformed string literal from ARM transformation functions invoked with arguments that are all string literals #6765

Conversation

jeskew
Copy link
Contributor

@jeskew jeskew commented May 4, 2022

Resolves #4134

This PR uses the ARM Expressions library to derive literal return types for ARM functions when invoked with arguments that are themselves all literal types. At present, this is only possible for ARM functions that take one or more string arguments and return a single string, but the pattern could be applied to other deterministic ARM function signatures if Bicep adds literal specializations for other primitive types.

Contributing a feature

  • I have opened a new issue for the proposal, or commented on an existing one, and ensured that the Bicep maintainers are good with the design of the feature being implemented
  • I have included "Fixes #{issue_number}" in the PR description, so GitHub can link to the issue and close it when the PR is merged
  • I have appropriate test coverage of my new feature
Microsoft Reviewers: Open in CodeFlow

…oked with arguments that are all string literals
@jeskew jeskew requested a review from a team May 4, 2022 17:15
@@ -513,6 +515,73 @@ public static class SystemNamespaceType
return fileUri;
}

private static TypeSymbol Base64ToStringTypeBuilder(IBinder binder, IFileResolver fileResolver, IDiagnosticWriter diagnostics, ImmutableArray<FunctionArgumentSyntax> arguments, ImmutableArray<TypeSymbol> argumentTypes)
Copy link
Contributor

Choose a reason for hiding this comment

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

The type builders are created to provide different armFunctionName to PerformArmConversionOfStringLiterals only, but their signatures are identical. Maybe it's worth extracting a higher order function to parameterize armFunctionName?

Copy link
Contributor

@shenglol shenglol left a comment

Choose a reason for hiding this comment

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

:shipit:

@jeskew jeskew merged commit aff0c95 into main May 4, 2022
@jeskew jeskew deleted the jeskew/return-transformed-string-literals-when-string-literal-passed-to-string-transformation-function branch May 4, 2022 21:13
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.

toLower(), toUpper() turns any string literal type into a generic 'string
2 participants