Commit e00b2fc
authored
Improve compiler detection of invalid runtime value usages. (Azure#10250)
* Remove the index expression check.
* Add test cases for diagnostics against a non-deploy time expression in for body expressions.
* Renames.
* Update the test cases.
* Remove this, merged into other test due to overlap.
* Consider non-string usages as collection access. String usages would really be property based access.
* Try to evaluate string literals up through variables when checking array access index expressions for dtc violations.
* Add test for variable stack.
* Add a baseline for runtime value tests. Pick a select set of permutations from the var for body scenario set for the baseline.
* Remove some diagnostic noise.
* Change the condition to just exclude integer literal syntax. The scope of this code should only be concerned about string-based property access and multiple types of syntax can evaluate to a string literal. Add more test cases.
* Partially revert commit 5498623. Semantic model's get type info should be used instead.
* Use semantic model GetTypeInfo to do index expression type checks to make DTC validation more robust.
* Split the tests so it's more debuggable. Leave TODO about union checking.
* Revert.
* Update baselines.
* Formatting.
* Add string literal checking for all-string unions. Add tests.
Remove the check for integer literal. I think string based property access is the only thing that needs to be checked here. If a resource is resolvable and something else is used, it's going to be a type error, so having the dtc diagnostic and type diagnostic visible at the same time will make it easier for the programmer to figure out what to do next.
* Add tests for nested resource access.
* Fix entire resource cases.
* Replicate the logic changes from direct visitor to indirect visitor. Test progress.
* Fix test cases expectation of indirect usages of param values to expect BCP78 instead of BCP182.
* Fix copy-paste error.. this visitor was using this method instead.
* Reduce duplication.
* Add some more nested resource test variants. Remove redundant checks.
* Action, not Func.
* Fix incorrect diagnostic.
* Refactor to function.
* Add existing resource tests.
* Add interpolated object property key tests.
* Rename the tests. This does not apply to all for body expression contexts.
* PR feedback: Move exhaustive cases to the baselines.
* PR feedback: include the violating property name in the diagnostic. This will allow displaying multiple diagnostics if there's union types involved.
* PR feedback: Reduce the complexity of the scenario tests. Also add the property name to the diagnostic for the indirect case.
* Update baselines.
* Update the json baseline files. Update README.
* Add some expression variants.
* Add a conditional resource collection accessor case.
* Add a test for string array accessor with type any. any() is meant to resolve type errors while DTC is a runtime concept.
* Fix gap of not checking for any or union of ints when checking dtc for whole resource access.
* Fix typo.1 parent bf6aac5 commit e00b2fc
File tree
65 files changed
+11783
-730
lines changed- src
- Bicep.Core.IntegrationTests
- Bicep.Core.Samples
- Files
- InvalidResources_CRLF
- Completions
- InvalidRuntimeValueUsages_LF
- InvalidVariables_LF
- ValidDeployTimeUsages_LF
- Bicep.Core
- Diagnostics
- TypeSystem
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
65 files changed
+11783
-730
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
Lines changed: 145 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| |||
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
13 | 45 | | |
14 | 46 | | |
15 | 47 | | |
| |||
41 | 73 | | |
42 | 74 | | |
43 | 75 | | |
44 | | - | |
| 76 | + | |
45 | 77 | | |
46 | 78 | | |
47 | 79 | | |
| |||
73 | 105 | | |
74 | 106 | | |
75 | 107 | | |
76 | | - | |
| 108 | + | |
77 | 109 | | |
78 | 110 | | |
79 | 111 | | |
| |||
126 | 158 | | |
127 | 159 | | |
128 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
129 | 272 | | |
130 | 273 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
| |||
Lines changed: 17 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5209 | 5209 | | |
5210 | 5210 | | |
5211 | 5211 | | |
5212 | | - | |
5213 | | - | |
5214 | | - | |
5215 | | - | |
5216 | | - | |
5217 | | - | |
5218 | | - | |
5219 | | - | |
5220 | | - | |
5221 | | - | |
5222 | | - | |
5223 | | - | |
5224 | | - | |
5225 | | - | |
5226 | | - | |
5227 | | - | |
5228 | | - | |
5229 | 5212 | | |
5230 | 5213 | | |
5231 | 5214 | | |
| |||
5257 | 5240 | | |
5258 | 5241 | | |
5259 | 5242 | | |
| 5243 | + | |
| 5244 | + | |
| 5245 | + | |
| 5246 | + | |
| 5247 | + | |
| 5248 | + | |
| 5249 | + | |
| 5250 | + | |
| 5251 | + | |
| 5252 | + | |
| 5253 | + | |
| 5254 | + | |
| 5255 | + | |
| 5256 | + | |
| 5257 | + | |
| 5258 | + | |
| 5259 | + | |
5260 | 5260 | | |
5261 | 5261 | | |
5262 | 5262 | | |
| |||
Lines changed: 17 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5173 | 5173 | | |
5174 | 5174 | | |
5175 | 5175 | | |
5176 | | - | |
5177 | | - | |
5178 | | - | |
5179 | | - | |
5180 | | - | |
5181 | | - | |
5182 | | - | |
5183 | | - | |
5184 | | - | |
5185 | | - | |
5186 | | - | |
5187 | | - | |
5188 | | - | |
5189 | | - | |
5190 | | - | |
5191 | | - | |
5192 | | - | |
5193 | 5176 | | |
5194 | 5177 | | |
5195 | 5178 | | |
| |||
5221 | 5204 | | |
5222 | 5205 | | |
5223 | 5206 | | |
| 5207 | + | |
| 5208 | + | |
| 5209 | + | |
| 5210 | + | |
| 5211 | + | |
| 5212 | + | |
| 5213 | + | |
| 5214 | + | |
| 5215 | + | |
| 5216 | + | |
| 5217 | + | |
| 5218 | + | |
| 5219 | + | |
| 5220 | + | |
| 5221 | + | |
| 5222 | + | |
| 5223 | + | |
5224 | 5224 | | |
5225 | 5225 | | |
5226 | 5226 | | |
| |||
Lines changed: 17 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5201 | 5201 | | |
5202 | 5202 | | |
5203 | 5203 | | |
5204 | | - | |
5205 | | - | |
5206 | | - | |
5207 | | - | |
5208 | | - | |
5209 | | - | |
5210 | | - | |
5211 | | - | |
5212 | | - | |
5213 | | - | |
5214 | | - | |
5215 | | - | |
5216 | | - | |
5217 | | - | |
5218 | | - | |
5219 | | - | |
5220 | | - | |
5221 | 5204 | | |
5222 | 5205 | | |
5223 | 5206 | | |
| |||
5249 | 5232 | | |
5250 | 5233 | | |
5251 | 5234 | | |
| 5235 | + | |
| 5236 | + | |
| 5237 | + | |
| 5238 | + | |
| 5239 | + | |
| 5240 | + | |
| 5241 | + | |
| 5242 | + | |
| 5243 | + | |
| 5244 | + | |
| 5245 | + | |
| 5246 | + | |
| 5247 | + | |
| 5248 | + | |
| 5249 | + | |
| 5250 | + | |
| 5251 | + | |
5252 | 5252 | | |
5253 | 5253 | | |
5254 | 5254 | | |
| |||
Lines changed: 17 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5432 | 5432 | | |
5433 | 5433 | | |
5434 | 5434 | | |
5435 | | - | |
5436 | | - | |
5437 | | - | |
5438 | | - | |
5439 | | - | |
5440 | | - | |
5441 | | - | |
5442 | | - | |
5443 | | - | |
5444 | | - | |
5445 | | - | |
5446 | | - | |
5447 | | - | |
5448 | | - | |
5449 | | - | |
5450 | | - | |
5451 | | - | |
5452 | 5435 | | |
5453 | 5436 | | |
5454 | 5437 | | |
| |||
5480 | 5463 | | |
5481 | 5464 | | |
5482 | 5465 | | |
| 5466 | + | |
| 5467 | + | |
| 5468 | + | |
| 5469 | + | |
| 5470 | + | |
| 5471 | + | |
| 5472 | + | |
| 5473 | + | |
| 5474 | + | |
| 5475 | + | |
| 5476 | + | |
| 5477 | + | |
| 5478 | + | |
| 5479 | + | |
| 5480 | + | |
| 5481 | + | |
| 5482 | + | |
5483 | 5483 | | |
5484 | 5484 | | |
5485 | 5485 | | |
| |||
0 commit comments