Skip to content

fix problem with loop optimization (#742)#756

Closed
dsyme wants to merge 2 commits into
dotnet:masterfrom
dsyme:fix-742
Closed

fix problem with loop optimization (#742)#756
dsyme wants to merge 2 commits into
dotnet:masterfrom
dsyme:fix-742

Conversation

@dsyme

@dsyme dsyme commented Dec 3, 2015

Copy link
Copy Markdown
Contributor

Provides a modified and reviewed fix for the problem reported here: #742

I've made the code cleaner and added additional constraints to ensure the optimization only applies to the compiled forms of for ... in ... do ... loops

@dsyme dsyme changed the title fix problem with loop optimization fix problem with loop optimization (#742) Dec 3, 2015
@robertpi

robertpi commented Dec 3, 2015

Copy link
Copy Markdown
Contributor

Cool. Looks good. I did wonder if checking the value in the enumerator and previous let binding was possible, but thought what I had was good enough. Would never have thought to make the change in the type checker either.

Comment thread tests/fsharp/core/seq/test.fsx Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In lieu of GitHub not lasting forever, one line of context would be helpful

@KevinRansom

Copy link
Copy Markdown
Contributor

Thanks for fixing this merged.

@dsyme

dsyme commented Dec 5, 2015

Copy link
Copy Markdown
Contributor Author

A not-so-pretty workaround for this issue is here: #759 (comment). (note however it requires changes to user code)

Comment thread src/fsharp/TastOps.fs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don is this right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think so - is there something I've missed? The "bodyExpr" is the body of the while loop, but it shouldn't directly refer to either enumerableVar (the variable holding the enumerable collection, which is consumed in GetEnumeratorCall) or enumeratorVar (the variable holding the enumerator for the collection, which is consumed in the binding for the elemVar "let").

@KevinRansom

Copy link
Copy Markdown
Contributor

On the internal build this fails with:

D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj" (BuildLinked target) (43:63) ->
CoreCompile target) ->
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7768,23): error FS0010: Unexpected identifier in expression. Expecte
 'in' or other token. [D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7769,23): error FS0058: Possible incorrect indentation: this token i
 offside of context started at position (7767:23). Try indenting this token further or using standard formatting convention
. [D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7769,23): error FS0058: Possible incorrect indentation: this token i
 offside of context started at position (7767:23). Try indenting this token further or using standard formatting convention
. [D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7772,9): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7767:23). Try indenting this token further or using standard formatting conventions
 [D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7773,9): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7772:9). Try indenting this token further or using standard formatting conventions.
[D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7775,9): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7773:9). Try indenting this token further or using standard formatting conventions.
[D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7776,9): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7775:9). Try indenting this token further or using standard formatting conventions.
[D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7777,9): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7776:9). Try indenting this token further or using standard formatting conventions.
[D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7783,1): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7777:9). Try indenting this token further or using standard formatting conventions.
[D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7791,1): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7783:1). Try indenting this token further or using standard formatting conventions.
[D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7793,1): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7783:1). Try indenting this token further or using standard formatting conventions.
[D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7800,5): error FS0010: Incomplete structured construct at or before
his point in definition. Expected incomplete structured construct at or before this point or other token. [D:\fsharp_D14\sr
\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]
 D:\fsharp_D14\src\fsharp\devdiv\src\fsharp\tastops.fs(7868,1): error FS0058: Possible incorrect indentation: this token is
offside of context started at position (7793:1). Try indenting this token further or using standard formatting conventions.
[D:\fsharp_D14\src\fsharp\projects\Prototype.FSharp.Compiler\FSharp.Compiler.fsproj]````
The OSS build succeeds though.

@mexx

mexx commented Dec 6, 2015

Copy link
Copy Markdown
Contributor

fails for me also in the wild ;) already on the FSharp.Compiler-proto.dll

mexx added a commit to mexx/visualfsharp that referenced this pull request Dec 6, 2015
@mexx mexx mentioned this pull request Dec 6, 2015
@enricosada

Copy link
Copy Markdown
Contributor

why this difference with appveyor build?

@mexx

mexx commented Dec 7, 2015

Copy link
Copy Markdown
Contributor

I think it's a matter of what fsc version is used to build the proto compiler, will check which version was used in my setup.

@mexx

mexx commented Dec 7, 2015

Copy link
Copy Markdown
Contributor

Here is the start of the failing call on my setup
..\..\..\lkg\FSharp-4.0.30319.1\bin\fsc.exe -o:obj\Proto\net40\FSharp.Build-proto.dll ...
on AppVeyor
C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe -o:obj\Proto\net40\FSharp.Build-proto.dll

@KevinRansom

Copy link
Copy Markdown
Contributor

the appveyor build uses F# 3.1, that is the difference between build success and failure. It fails with the LKG.

@mexx

mexx commented Dec 8, 2015

Copy link
Copy Markdown
Contributor

What are the reasons why AppVeyor build doesn't use the LKG version, like the local ones?
Shouldn't the build take the same path as local ones?

KevinRansom pushed a commit that referenced this pull request Dec 8, 2015
KevinRansom pushed a commit that referenced this pull request Dec 8, 2015
@KevinRansom

Copy link
Copy Markdown
Contributor

It'seems a bug in the script, we are looking at fixing it.

@KevinRansom

Copy link
Copy Markdown
Contributor

pulled

@KevinRansom KevinRansom closed this Dec 9, 2015
dsyme added a commit to fsharp/fsharp-compiler-docs that referenced this pull request Dec 14, 2015
dsyme added a commit to fsharp/fsharp-compiler-docs that referenced this pull request Dec 14, 2015
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.

7 participants