Skip to content

Commit

Permalink
Fix dotnet#38
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyme committed Jan 20, 2015
1 parent 481890d commit bba3959
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/fsharp/tc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4538,7 +4538,14 @@ and TcTypeOrMeasureAndRecover optKind cenv newOk checkCxs occ env tpenv ty =
try TcTypeOrMeasure optKind cenv newOk checkCxs occ env tpenv ty
with e ->
errorRecovery e ty.Range
(if newOk <> NoNewTypars then NewErrorType () else cenv.g.obj_ty),tpenv
let rty =
match optKind, newOk with
| Some TyparKind.Measure, NoNewTypars -> TType_measure MeasureOne
| Some TyparKind.Measure, _ -> TType_measure (NewErrorMeasure ())
| _, NoNewTypars -> cenv.g.obj_ty
| _ -> NewErrorType ()
rty,tpenv


and TcTypeAndRecover cenv newOk checkCxs occ env tpenv ty =
TcTypeOrMeasureAndRecover (Some TyparKind.Type) cenv newOk checkCxs occ env tpenv ty
Expand Down
4 changes: 4 additions & 0 deletions tests/fsharp/typecheck/sigs/neg90.bsl
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@

neg90.fs(4,9,4,12): typecheck error FS0001: A generic construct requires that the type 'Recd' have a public default constructor

neg90.fs(7,22,7,25): typecheck error FS0039: The type 'foo' is not defined

neg90.fs(7,22,7,25): typecheck error FS0039: The type 'foo' is not defined
6 changes: 5 additions & 1 deletion tests/fsharp/typecheck/sigs/neg90.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module Test
let foo<'a when 'a : (new : unit -> 'a)>() = new 'a()
type Recd = {f : int}
let _ = foo<Recd>()
let _ = foo<Recd>()

// See https://github.com/Microsoft/visualfsharp/issues/38
type [<Measure>] N = foo // foo is undefined
type M2 = float<N>

0 comments on commit bba3959

Please sign in to comment.