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

Use languageVersion 2.0 if any types are imported #11886

Merged
merged 2 commits into from
Sep 19, 2023
Merged

Use languageVersion 2.0 if any types are imported #11886

merged 2 commits into from
Sep 19, 2023

Conversation

jeskew
Copy link
Contributor

@jeskew jeskew commented Sep 19, 2023

Resolves #11881

Bicep will use languageVersion: 2.0 in compiled templates if the source template contains any type statements or uses type expressions that will result in ARM syntax only supported in language version 2.0. The compiler needs to also check if there were any import statements that pull in user-defined types, as that will also result in a template with syntax requiring language version 2.0.

Microsoft Reviewers: Open in CodeFlow

@jeskew jeskew requested a review from a team September 19, 2023 14:27
@github-actions
Copy link
Contributor

github-actions bot commented Sep 19, 2023

Test this change out locally with the following install scripts (Action run 6239527020)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 6239527020
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 6239527020"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 6239527020
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 6239527020"

@github-actions
Copy link
Contributor

github-actions bot commented Sep 19, 2023

Test Results

     132 files  ±0       132 suites  ±0   3h 36m 44s ⏱️ + 21m 11s
10 541 tests +2  10 541 ✔️ +2  0 💤 ±0  0 ±0 
50 715 runs  +8  50 715 ✔️ +8  0 💤 ±0  0 ±0 

Results for commit a3e777c. ± Comparison against base commit 547c9c4.

♻️ This comment has been updated with latest results.

@majastrz
Copy link
Member

                    syntax is NullableTypeSyntax,

Out of scope of the PR, but should we have an interface or a base type to indicate that the syntax node declares a user defined type? We use that approach in other places with symbols or even some syntax nodes to easily discover that something is an expression node and such.


Refers to: src/Bicep.Core/Emit/EmitterSettings.cs:36 in a3e777c. [](commit_id = a3e777c, deletion_comment = False)

Copy link
Member

@majastrz majastrz 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
Copy link
Contributor Author

jeskew commented Sep 19, 2023

                    syntax is NullableTypeSyntax,

Out of scope of the PR, but should we have an interface or a base type to indicate that the syntax node declares a user defined type? We use that approach in other places with symbols or even some syntax nodes to easily discover that something is an expression node and such.

Refers to: src/Bicep.Core/Emit/EmitterSettings.cs:36 in a3e777c. [](commit_id = a3e777c, deletion_comment = False)

I like that idea. There is a TypeSyntax base class that all of syntax types checked for here extend, but checking for that would also catch resource-typed params and outputs. I can add an IArmTypeConstrainingExpression interface (open to suggestions on the name).

@jeskew jeskew merged commit 668b5e2 into main Sep 19, 2023
47 checks passed
@jeskew jeskew deleted the jeskew/11881 branch September 19, 2023 18:29
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.

Compile-time imports with nested types, receives an AggregateTypeValidation error
2 participants