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

index loop syntax #1790

Merged
merged 1 commit into from
Mar 9, 2021
Merged

index loop syntax #1790

merged 1 commit into from
Mar 9, 2021

Conversation

majastrz
Copy link
Member

@majastrz majastrz commented Mar 9, 2021

Implemented loop index syntax. This fixes #1617.

LoopSnippetIndexed

var inaccessibleLocals = this.context.DataFlowAnalyzer.GetInaccessibleLocalsAfterSyntaxMove(nameSyntax, newContext);
switch (inaccessibleLocals.Count)
var inaccessibleLocalLoops = inaccessibleLocals.Select(local => GetEnclosingForExpression(local)).Distinct().ToList();
Copy link
Member Author

Choose a reason for hiding this comment

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

inaccessibleLocalLoops [](start = 16, length = 22)

Most of the changes in this file are to remove code duplication between the paths involved in indexed collection access and normal locals replacement.

@majastrz
Copy link
Member Author

majastrz commented Mar 9, 2021

    public LocalKind LocalKind { get; }

Having this simplifies code gen a bit.


Refers to: src/Bicep.Core/Semantics/LocalVariableSymbol.cs:22 in f5bfed6. [](commit_id = f5bfed6, deletion_comment = False)

@majastrz
Copy link
Member Author

majastrz commented Mar 9, 2021

    public SyntaxBase VariableSection { get; }

I'm not particularly fond of this name. Another option: ItemVariableOrVariableBlock. Thoughts?


Refers to: src/Bicep.Core/Syntax/ForSyntax.cs:45 in f5bfed6. [](commit_id = f5bfed6, deletion_comment = False)

@majastrz majastrz marked this pull request as ready for review March 9, 2021 04:43
@majastrz majastrz force-pushed the majastrz/loop-index branch from f5bfed6 to 5be605b Compare March 9, 2021 07:55
Copy link
Member

@anthony-c-martin anthony-c-martin left a comment

Choose a reason for hiding this comment

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

LGTM!

@majastrz majastrz force-pushed the majastrz/loop-index branch from 5be605b to 8b0c41a Compare March 9, 2021 22:38
@codecov-io
Copy link

codecov-io commented Mar 9, 2021

Codecov Report

Merging #1790 (8b0c41a) into main (1ac5ae4) will decrease coverage by 0.04%.
The diff coverage is 92.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1790      +/-   ##
==========================================
- Coverage   95.07%   95.03%   -0.05%     
==========================================
  Files         370      371       +1     
  Lines       21543    21690     +147     
  Branches       15       15              
==========================================
+ Hits        20483    20613     +130     
- Misses       1060     1077      +17     
Flag Coverage Δ
dotnet 95.47% <92.45%> (-0.05%) ⬇️
typescript 26.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../Bicep.Core.UnitTests/Assertions/BaselineHelper.cs 79.54% <ø> (ø)
src/Bicep.Core/Parsing/Parser.cs 98.19% <ø> (+0.03%) ⬆️
src/Bicep.Core/PrettyPrint/DocumentBuildVisitor.cs 100.00% <ø> (ø)
src/Bicep.Core/Semantics/DeclarationVisitor.cs 98.52% <ø> (+0.14%) ⬆️
src/Bicep.Core/Semantics/LocalVariableSymbol.cs 85.71% <ø> (-14.29%) ⬇️
src/Bicep.Core/Syntax/ForSyntax.cs 96.07% <ø> (-3.93%) ⬇️
src/Bicep.Core/Syntax/ForVariableBlockSyntax.cs 100.00% <ø> (ø)
src/Bicep.Core/Syntax/LocalVariableSyntax.cs 100.00% <ø> (ø)
src/Bicep.Core/Syntax/SyntaxRewriteVisitor.cs 75.94% <ø> (-2.43%) ⬇️
src/Bicep.Core/Syntax/SyntaxVisitor.cs 95.93% <ø> (+0.14%) ⬆️
... and 19 more

@majastrz majastrz merged commit 5844076 into main Mar 9, 2021
@majastrz majastrz deleted the majastrz/loop-index branch March 9, 2021 23:21
@majastrz majastrz added this to the v0.4 milestone Mar 9, 2021
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.

Implement loop index syntax
3 participants