-
Notifications
You must be signed in to change notification settings - Fork 747
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
When using a parameter with an imported user-defined type array, template compilation fails #12052
Comments
I started compiling more templates where non array custom types are defined and they are failing as well. The sample modified to the following is also failing: import {Foo} from 'types.bicep'
param foo Foo = {
bar: false
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.21.1.54444",
"templateHash": "13878968526056156201"
}
},
"definitions": {
"Foo": {
"type": "object",
"properties": {
"bar": {
"type": "bool"
}
},
"metadata": {
"__bicep_imported_from!": {
"sourceTemplate": "types.bicep"
}
}
}
},
"parameters": {
"foo": {
"$ref": "#/definitions/Foo",
"defaultValue": {
"bar": false
}
}
},
"resources": []
}
If the |
Thanks for reporting, @GABRIELNGBTUC! This reflected a gap in the test coverage for type imports that should be addressed by the linked PR. If this bug is blocking you from executing needed deployments, there is a workaround you can use. The underlying issue will cause the error you encountered when an imported type is used in a import {Foo} from 'types.bicep'
type myFoo = Foo // <-- creating an alias for use in param and output statements avoids the issue
param foo myFoo = {
bar: false
} |
…ses (#12055) Resolves #12052 A recent PR (#12048) updated TemplateWriter to preprocess a template's references to imported symbols. This new step uses an `ExpressionRewriteVisitor`, which had not been kept up to date when new properties were added various kinds of IR expressions. The PR also adds a few more lines to the `Imports_LF` baseline scenario to exercise additional behavior. The scenario had originally been written to validate the mechanics of importing types and variables but didn't cover the mechanics of *using* imported symbols in a template. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/12055)
Bicep version
Bicep CLI version 0.22.6 (d62b94d)
VS code extension was directly installed from the provided .vsix in the release tab from GitHub
Describe the bug
When upgrading to the 0.22.6, any template that has a parameter type
CustomType[]
whereCustomType
is imported now fails to compileTo Reproduce
main.bicep:
types.bicep:
In 0.21.1,
az bicep build -f main.bicep
compiles to the followingIn 0.22.6, running the same commands fails with the following error:
The text was updated successfully, but these errors were encountered: