Skip to content

Commit

Permalink
fix for private val set
Browse files Browse the repository at this point in the history
fixes #27
resolves #28

commit bf3c9b3ff6151a09dd9319e5e54d21a0edd17c31
Merge: 5eb0657 7393d92
Author: latkin <[email protected]>
Date:   Mon Jan 19 16:57:58 2015 -0800

    Merge branch 'private-val-fix' of https://github.com/dsyme/visualfsharp into dsyme-private-val-fix

commit 7393d92
Author: Don Syme <[email protected]>
Date:   Sat Jan 17 11:50:54 2015 +0000

    add tests for val sets

commit 68555a3
Author: Don Syme <[email protected]>
Date:   Sat Jan 17 11:38:18 2015 +0000

    adjust range reported in error

commit bff938f
Author: Don Syme <[email protected]>
Date:   Sat Jan 17 11:35:08 2015 +0000

    fix compile

commit d2f12e4
Author: Don Syme <[email protected]>
Date:   Sat Jan 17 11:33:41 2015 +0000

    fix for private val set
  • Loading branch information
dsyme authored and forki committed Jan 21, 2015
1 parent 10e2012 commit c35937f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/fsharp/tc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8146,6 +8146,9 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution
| DelayedSet(e2,mStmt) :: otherDelayed ->
if nonNil otherDelayed then error(Error(FSComp.SR.tcInvalidAssignment(),mStmt))
UnifyTypes cenv env mStmt overallTy cenv.g.unit_ty
vref.Deref.SetHasBeenReferenced()
CheckValAccessible mItem env.eAccessRights vref
CheckValAttributes cenv.g vref mItem |> CommitOperationResult
let vty = vref.Type
let vty2 =
if isByrefTy cenv.g vty then
Expand Down
8 changes: 8 additions & 0 deletions tests/fsharp/typecheck/sigs/neg91.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
neg91.fs(7,16,7,30): typecheck error FS0896: Enumerations cannot have members

neg91.fs(10,10,10,15): typecheck error FS0956: Members that extend interface, delegate or enum types must be placed in a module separate to the definition of the type. This module must either have the AutoOpen attribute or be opened explicitly by client code to bring the extension members into scope.

neg91.fs(24,13,24,16): typecheck error FS1094: The value 'x' is not accessible from this code location

neg91.fs(34,13,34,16): typecheck error FS0044: This construct is deprecated. Don't touch me

neg91.fs(44,13,44,16): typecheck error FS3003: Don't touch me

neg91.fs(54,13,54,16): typecheck error FS0057: It was just an experiment!. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.
41 changes: 41 additions & 0 deletions tests/fsharp/typecheck/sigs/neg91.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,44 @@ module T2 =
type Enum2
with
member this.Foo() = 1 // not ok

module TestPrivateSet =
// See https://github.com/Microsoft/visualfsharp/issues/27
module A =
let mutable private x = 0

module B =
let test () =
// let _ = A.x // accessibility error on read, as expected
A.x <- 1 // but write works!

module TestObsoleteSet =
// See https://github.com/Microsoft/visualfsharp/issues/27
module A =
[<System.ObsoleteAttribute("Don't touch me")>]
let mutable x = 0

module B =
let test () =
A.x <- 1

module TestCompilerMessgeSet =
// See https://github.com/Microsoft/visualfsharp/issues/27
module A =
[<CompilerMessageAttribute("Don't touch me", 3003)>]
let mutable x = 0

module B =
let test () =
A.x <- 1

module TestExperimentalSet =
// See https://github.com/Microsoft/visualfsharp/issues/27
module A =
[<ExperimentalAttribute("It was just an experiment!")>]
let mutable x = 0

module B =
let test () =
A.x <- 1

6 changes: 3 additions & 3 deletions tests/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,6 @@ Misc02 fsharp\regression\tuple-bug-1
Misc02 fsharp\tools\bundle
Misc02 fsharp\tools\eval
Misc02 ..\testsprivate\fsharp\tools\queries
Misc02 fsharp\typecheck\misc
Misc02 fsharp\typecheck\sigs
Misc02 fsharp\typecheck\full-rank-arrays
Misc02,TypeChecker fsharp\typecheck\misc
Misc02,TypeChecker fsharp\typecheck\sigs
Misc02,TypeChecker fsharp\typecheck\full-rank-arrays

0 comments on commit c35937f

Please sign in to comment.