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

[WIP] fix for #4956 (TP error reporting) #4978

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/fsharp/tainted.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ type internal Tainted<'T> (context : TaintedContext, value : 'T) =
member this.TypeProviderAssemblyRef =
context.TypeProviderAssemblyRef

member this.Protect f (range:range) =
member this.Protect f (range:range) =
try
f value
with
| :? TypeProviderError -> reraise()
| :? AggregateException as ae ->
let errNum,_ = FSComp.SR.etProviderError("", "")
let messages = [for e in ae.InnerExceptions -> e.Message]
let messages = [for e in ae.InnerExceptions -> string e]
raise <| TypeProviderError(errNum, this.TypeProviderDesignation, range, messages)
| e ->
let errNum,_ = FSComp.SR.etProviderError("", "")
raise <| TypeProviderError((errNum, e.Message), this.TypeProviderDesignation, range)
raise <| TypeProviderError((errNum, string e), this.TypeProviderDesignation, range)

member this.TypeProvider = Tainted<_>(context, context.TypeProvider)

Expand Down
1 change: 1 addition & 0 deletions tests/fsharp/TypeProviderTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ let ``negative type provider tests`` (name:string) =
File.ReadAllText(sprintf "%s%s.%sbslpp" dirp name pref)
.Replace("<ASSEMBLY>", getfullpath cfg (sprintf "provider_%s.dll" name))
.Replace("<URIPATH>",sprintf "file:///%s" dirp)
.Replace("<REPOSITORYROOT>", (Path.Combine(__SOURCE_DIRECTORY__, "..", "..") |> DirectoryInfo).FullName)
|> fun txt -> File.WriteAllText(sprintf "%s%s.%sbsl" dirp name pref,txt)

if name = "ProviderAttribute_EmptyConsume" || name = "providerAttributeErrorConsume" then ()
Expand Down
58 changes: 58 additions & 0 deletions tests/fsharp/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Folder organization

This folder contains a set of test suites related to fsc and fsi.

## EndToEndBuildTests

To be described.

## fsharp

An heterogenous set of tests.

### about .bsl based tests (baseline)

Some of the tests in this suite are checking the compiler output messages against an expected baseline; the baseline is stored in .bslpp or .bsl files and after the test is run, an associated .err or .vserr file is expected to be matching the baseline.

.bslpp indicates a preprocess baseline, which is transformed on the test environment into a .bsl file before the diff is performed.

You can look at the `diff` function in single-test.fs.

`Test.fs` file can be used in interactive, for example you can send the top of it and run a single test

```fsharp
singleNegTest (testConfig "typecheck/sigs") "neg1"
```

If you want to update all the baseline files, you can also use the convenience script `update.base.line.with.actuals.fsx`, note that the .bslpp will need to have their preprocess peculiarities edited back in (or reverted) when using it.

## FSharp.Build.UnitTests

To be described.

## FSharp.Compiler.UnitTests

To be described.

## FSharp.Core.UnitTests

To be described.

## fsharpqa

To be described.

## projects

To be described.

## scripts

To be described.

## service

To be described.

## walkthroughs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

EVIL_PROVIDER_GetInvokerExpression_Exception.fsx(7,9,7,80): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereApplyGetInvokerExpressionRaisesException' reported an error in the context of provided type 'FSharp.EvilProviderWhereGetInvokerExpressionRaisesException.TheType', member 'get_Foo'. The error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_GetInvokerExpression_Exception>.$Provider$fsx.-ctor@242-7.Invoke(Unit _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.GetInvokerExpression(ITypeProvider provider, ProvidedMethodBase methodBase, ProvidedVar[] paramExprs) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 891

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

EVIL_PROVIDER_GetNamespaces_Exception.fsx(2,1,2,56): parse error FS3033: The type provider 'Provider.EvilProviderWhereGetNamespacesRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_GetNamespaces_Exception>.$Provider$fsx.-ctor@224-7.Invoke(Unit _arg28)

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_GetNamespaces_Exception.fsx(2,1,2,56): parse error FS3020: One or more errors seen during provided type setup

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

EVIL_PROVIDER_GetNestedNamespaces_Exception.fsx(2,1,2,62): parse error FS3033: The type provider 'Provider.EvilProviderWhereGetNestedNamespacesRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_GetNestedNamespaces_Exception>.$Provider$fsx.-ctor@200-7.Invoke(Unit _arg28)

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_GetNestedNamespaces_Exception.fsx(2,1,2,62): parse error FS3020: One or more errors seen during provided type setup

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

EVIL_PROVIDER_GetStaticParameters_Exception.fsx(7,18,7,84): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereGetStaticParametersRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_GetStaticParameters_Exception>.$Provider$fsx.-ctor@230-7.Invoke(Unit _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.ProvidedType.GetStaticParameters(ITypeProvider provider) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 425

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_GetStaticParameters_Exception.fsx(7,18,7,84): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereGetStaticParametersRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_GetStaticParameters_Exception>.$Provider$fsx.-ctor@230-7.Invoke(Unit _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.ProvidedType.GetStaticParameters(ITypeProvider provider) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 425

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

EVIL_PROVIDER_GetTypes_Exception.fsx(2,1,2,51): parse error FS3033: The type provider 'Provider.EvilProviderWhereGetTypesRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_GetTypes_Exception>.$Provider$fsx.-ctor@212-7.Invoke(Unit _arg28)

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_GetTypes_Exception.fsx(2,1,2,51): parse error FS3020: One or more errors seen during provided type setup

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

EVIL_PROVIDER_NamespaceName_Exception.fsx(1,1,1,56): parse error FS3033: The type provider 'Provider.EvilProviderWhereNamespaceNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_NamespaceName_Exception>.$Provider$fsx.-ctor@206-7.Invoke(Unit _arg28)

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_NamespaceName_Exception.fsx(1,1,1,56): parse error FS3020: One or more errors seen during provided type setup

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereResolveTypeNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_ResolveTypeName_Exception>.$Provider$fsx.-ctor@218-7.Invoke(String _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.resolvedType@1073.Invoke(IProvidedNamespace providedNamespace) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 1073

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereResolveTypeNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_ResolveTypeName_Exception>.$Provider$fsx.-ctor@218-7.Invoke(String _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.resolvedType@1073.Invoke(IProvidedNamespace providedNamespace) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 1073

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereResolveTypeNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_ResolveTypeName_Exception>.$Provider$fsx.-ctor@218-7.Invoke(String _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.resolvedType@1073.Invoke(IProvidedNamespace providedNamespace) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 1073

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereResolveTypeNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_ResolveTypeName_Exception>.$Provider$fsx.-ctor@218-7.Invoke(String _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.resolvedType@1073.Invoke(IProvidedNamespace providedNamespace) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 1073

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS0039: The type 'SomeNameThatDoesntExist' is not defined in 'FSharp.EvilProviderWhereResolveTypeNameRaisesException'.

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereResolveTypeNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_ResolveTypeName_Exception>.$Provider$fsx.-ctor@218-7.Invoke(String _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.resolvedType@1073.Invoke(IProvidedNamespace providedNamespace) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 1073

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereResolveTypeNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_ResolveTypeName_Exception>.$Provider$fsx.-ctor@218-7.Invoke(String _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.resolvedType@1073.Invoke(IProvidedNamespace providedNamespace) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 1073

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereResolveTypeNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_ResolveTypeName_Exception>.$Provider$fsx.-ctor@218-7.Invoke(String _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.resolvedType@1073.Invoke(IProvidedNamespace providedNamespace) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 1073

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS3033: The type provider 'Provider.EvilProviderWhereResolveTypeNameRaisesException' reported an error: System.Exception: deliberate error for testing purposes

at <StartupCode$provider_EVIL_PROVIDER_ResolveTypeName_Exception>.$Provider$fsx.-ctor@218-7.Invoke(String _arg28)

at Microsoft.FSharp.Compiler.ExtensionTyping.resolvedType@1073.Invoke(IProvidedNamespace providedNamespace) in <REPOSITORYROOT>\src\fsharp\ExtensionTyping.fs:line 1073

at Microsoft.FSharp.Compiler.Tainted`1.Protect[a](FSharpFunc`2 f, range range) in <REPOSITORYROOT>\src\fsharp\tainted.fs:line 94

EVIL_PROVIDER_ResolveTypeName_Exception.fsx(7,73,7,96): typecheck error FS0039: The type 'SomeNameThatDoesntExist' is not defined in 'FSharp.EvilProviderWhereResolveTypeNameRaisesException'.
Loading