Skip to content

Commit bc367dc

Browse files
committed
Merge branch 'to_string_null_fix' of https://github.com/rojepp/visualfsharp into rojepp-to_string_null_fix
2 parents 56fbb87 + 7ae2aca commit bc367dc

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/utils/sformat.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat
11941194
| :? bool as b -> (if b then "true" else "false")
11951195
| :? char as c -> "\'" + formatChar true c + "\'"
11961196
| _ -> try let text = obj.ToString()
1197-
text
1197+
if text = null then "" else text
11981198
with e ->
11991199
// If a .ToString() call throws an exception, catch it and use the message as the result.
12001200
// This may be informative, e.g. division by zero etc...
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// #Regression #NoMT #FSI
2+
// Microsoft.Analysis.Server overrides ToString() to return isNull
3+
// instead of a string. This would make FSI fail in pretty-printing
4+
// when displaying results.
5+
//<Expects status="success">val n : NullToString = </Expects>
6+
7+
type NullToString() =
8+
override __.ToString() = null;;
9+
10+
let n = NullToString();;
11+
#q;;
12+

tests/fsharpqa/Source/InteractiveSession/Misc/env.lst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ ReqENU SOURCE=E_InterfaceCrossConstrained02.fsx COMPILE_ONLY=1 FSIMODE=PIPE SC
2727

2828
SOURCE=EmptyList.fsx COMPILE_ONLY=1 FSIMODE=PIPE SCFLAGS="--nologo" # EmptyList.fsx
2929

30+
SOURCE=ToStringNull.fsx COMPILE_ONLY=1 FSIMODE=PIPE SCFLAGS="--nologo" # ToStringNull.fsx
31+
3032
# These are the regression tests for FSHARP1.0:5427
3133
# The scenario is a bit convoluted because of the way we end up doing the verification
3234
# In the last 2 cases, the verification is achieved by dumping the output of FSI to a file

0 commit comments

Comments
 (0)