FSI AddBoundValue should follow type forwards
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
The method [`AddBoundValue()`](https://github.com/dotnet/fsharp/blob/00f1c12d7a71a2642f8594543c7d0848829e6c9b/src/fsharp/fsi/fsi.fs#L1620) doesn't follow ref->impl type forwards which can cause problems at runtime. E.g., if a `net5.0` C# app calls into this method built against `netstandard2.0` and tries to add a bound value for an `int`, you won't be able to use the imported value because FSI is using the ref assemblies, but the value from C# is from a runtime implementation assembly.
E.g.,
``` csharp
// this is C#
var x = 1;
fsi.AddBoundValue(nameof(x), x);
fsi.Eval("x + 1")
```
`fsi` will report that the types `int` and `System.Int32` aren't compatible because one type comes from `System.Private.CoreLib` and the other from `System.Runtime`.
### Workaround
When instantiating the `fsi` object, the argument `/usesdkrefs-` will enable this scenario to work.
Contributor guide
Assessment
This issue has not been assessed yet.