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

Private val fix #28

Closed
wants to merge 4 commits into from
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
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 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the typo: TestCompilerMessageSet

// 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