Skip to content

Remove one "impossible" error#5746

Merged
KevinRansom merged 4 commits intodotnet:masterfrom
forki:i5745
Oct 15, 2018
Merged

Remove one "impossible" error#5746
KevinRansom merged 4 commits intodotnet:masterfrom
forki:i5745

Conversation

@forki
Copy link
Copy Markdown
Contributor

@forki forki commented Oct 9, 2018

image

fixes #5745

Comment thread src/fsharp/TypeChecker.fs Outdated
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.

But this case is impossible, correct? Shouldn't we report this somehow?

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.

"impossible"

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.

What I mean is that item is matched some lines above to be one of the two cases and item is immutable? This case means someone has changed something and missed to do some work. Removing failwith means the mistake will be spotted later (or not at all)

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.

actually that is what already happend. the case was added and nobody changed the failwith "impossible"

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.

But line above reads | (Item.UnionCase _ | Item.ExnCase _) as item -> how can this match another case?

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.

it does not today. wait until someone adds the active pattern part ;-)

Comment thread src/fsharp/TypeChecker.fs Outdated
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.

Should we still report that this error message might need to be refined (in case it happens)? Would this be an advantage of failwith "impossible" here?

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.

failwith "impossible" is arguably the worst you can do

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.

Yes ideally the code would be written in a way to not compile when written incorrectly, but if that cannot be achieved imho throwing is better than doing/reporting potentially incorrect messages

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.

Actually I think even having a confusing error message is better than what existed. The current state of the world (without @forki's changes) paints the whole editor red if you use the incorrect code:

screen shot 2018-10-09 at 07 28 16

These internal errors are critical to root out given this, since it's pretty much undiagnosable where the user error is.

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.

Ok but imho we still should make sure the error message indicates this is not implemented and something which needs to be fixed if it occurs.
Otherwise users get wrong messages on their code which is arguably worse than a compiler crash

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.

we don't give a wrong message. We just give a very generic one

@forki forki force-pushed the i5745 branch 4 times, most recently from 423564f to 89e498b Compare October 9, 2018 12:06
@forki
Copy link
Copy Markdown
Contributor Author

forki commented Oct 9, 2018

@KevinRansom is something wrong with master? the error for linux build seems unrelated

@KevinRansom
Copy link
Copy Markdown
Contributor

@forki not that I know. The error is:

2018-10-09T12:23:11.3515703Z   /home/vsts/work/1/s/src/scripts/scriptlib.fsx(65,25): error FS0041: A unique overload for method 'GetFileName' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: Path.GetFileName(path: ReadOnlySpan<char>) : ReadOnlySpan<char>, Path.GetFileName(path: string) : string [/home/vsts/work/1/s/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj]
2018-10-09T12:23:11.3517355Z   /home/vsts/work/1/s/src/FSharpSource.targets(208,5): error MSB3073: The command "mono /home/vsts/work/1/s/packages/FSharp.Compiler.Tools.4.1.27/tools/fsi.exe --exec "/home/vsts/work/1/s/src/scripts/subst.fsx" --in:"/home/vsts/work/1/s/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.dll.config" --out:"/home/vsts/work/1/s/tests/FSharp.Core.UnitTests/../../src/../release/net40/bin/FSharp.Core.UnitTests.dll.config" --pattern1:"FSCoreVersion" --replacement1:"4.5.0.0" --pattern2:"" --replacement2:"" " exited with code 1. [/home/vsts/work/1/s/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj]
2018-10-09T12:23:11.3517711Z 
2

At this point I believe the script is running the built compiler, so I suppose there is some possibility they are related.

@cartermp
Copy link
Copy Markdown
Contributor

cartermp commented Oct 9, 2018

@KevinRansom #5733 also has this error but with no compiler, so something's wrong in the linux build

@KevinRansom
Copy link
Copy Markdown
Contributor

@cartermp indeed it does.

@forki
Copy link
Copy Markdown
Contributor Author

forki commented Oct 10, 2018

it's noew green after rebase

@KevinRansom KevinRansom merged commit 39fd7b8 into dotnet:master Oct 15, 2018
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.

Illegal syntax in an active pattern produces an internal compiler error

5 participants