Skip to content

Commit b5e59d5

Browse files
Furthering the test, all languages exhibit the same issue.
Added another property that is expected to fail, exhibiting inconsistencies in how the error is reported depending if the type is defined in F# or not.
1 parent 827e5b8 commit b5e59d5

6 files changed

Lines changed: 64 additions & 19 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
calls.fsx(9,22,9,27): typecheck error FS0495: The object constructor 'Class' has no argument or settable return property 'Prop1'. The required signature is csharp.Class() : csharp.Class.
3+
4+
calls.fsx(10,26,10,31): typecheck error FS0495: The object constructor 'BasicClass' has no argument or settable return property 'Prop1'. The required signature is basic.BasicClass() : basic.BasicClass.
5+
6+
calls.fsx(13,21,13,26): typecheck error FS0495: The member or object constructor 'mkCs' has no argument or settable return property 'Prop1'. The required signature is static member Maker.mkCs : unit -> csharp.Class.
7+
8+
calls.fsx(14,21,14,26): typecheck error FS0495: The member or object constructor 'mkVb' has no argument or settable return property 'Prop1'. The required signature is static member Maker.mkVb : unit -> basic.BasicClass.
9+
10+
calls.fsx(18,30,18,31): typecheck error FS0629: Method 'set_Prop2' is not accessible from this code location
11+
12+
calls.fsx(19,34,19,35): typecheck error FS0629: Method 'set_Prop2' is not accessible from this code location
13+
14+
calls.fsx(20,24,20,29): typecheck error FS0495: The object constructor 'Class' has no argument or settable return property 'Prop2'. The required signature is new : unit -> fsharp.Class.
15+
16+
calls.fsx(22,29,22,30): typecheck error FS0629: Method 'set_Prop2' is not accessible from this code location
17+
18+
calls.fsx(23,29,23,30): typecheck error FS0629: Method 'set_Prop2' is not accessible from this code location
19+
20+
calls.fsx(24,23,24,28): typecheck error FS0495: The member or object constructor 'mkFs' has no argument or settable return property 'Prop2'. The required signature is static member Maker.mkFs : unit -> fsharp.Class.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#r "cs.dll"
2+
#r "vb.dll"
3+
#r "fs.dll"
4+
type Maker =
5+
static member mkCs () = csharp.Class()
6+
static member mkVb () = basic.BasicClass()
7+
static member mkFs () = fsharp.Class()
8+
// so long https://github.com/dotnet/fsharp/issues/8351 isn't fixed, Prop1 setters are failing
9+
let a = csharp.Class(Prop1=1)
10+
let b = basic.BasicClass(Prop1=1)
11+
let c = fsharp.Class(Prop1=1)
12+
13+
let aa = Maker.mkCs(Prop1=1)
14+
let bb = Maker.mkVb(Prop1=1)
15+
let cc = Maker.mkFs(Prop1=1)
16+
17+
// those are expected to fail, albeit with inconsistent error messages / marked ranges
18+
let aaa = csharp.Class(Prop2=1)
19+
let bbb = basic.BasicClass(Prop2=1)
20+
let ccc = fsharp.Class(Prop2=1)
21+
22+
let aaaa = Maker.mkCs(Prop2=1)
23+
let bbbb = Maker.mkVb(Prop2=1)
24+
let cccc = Maker.mkFs(Prop2=1)

tests/fsharp/core/members/set-only-property/cs.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace csharp
22
{
33
public class Class
44
{
5-
public int Prop { set; private get; }
6-
}
5+
public int Prop1 { set; private get; }
6+
public int Prop2 { private set; get; }
7+
}
78
}
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1+
namespace fsharp
12
type Class () =
23
let mutable v = 0
3-
member x.Prop with set(value) = v <- value
4-
and private get () = v
4+
member x.Prop1 with set(value) = v <- value
5+
and private get () = v
56

6-
let a = csharp.Class(Prop=1)
7-
let b = basic.BasicClass(Prop=1)
8-
let c = Class(Prop=1)
9-
10-
type Maker =
11-
static member mkCs () = csharp.Class()
12-
static member mkVb () = basic.BasicClass()
13-
static member mkFs () = Class()
14-
15-
let aa = Maker.mkCs(Prop=1)
16-
let bb = Maker.mkVb(Prop=1)
17-
let cc = Maker.mkFs(Prop=1)
7+
member x.Prop2 with private set(value) = v <- value
8+
and public get () = v
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
namespace basic
22
public class BasicClass
33
dim v as integer
4-
public property Prop as integer
4+
public property Prop1 as integer
55
private get
66
return v
77
end get
88
set(value as integer)
99
v = value
1010
end set
1111
end property
12+
public property Prop2 as integer
13+
get
14+
return v
15+
end get
16+
private set(value as integer)
17+
v = value
18+
end set
19+
end property
1220
end class
1321
end namespace

tests/fsharp/tests.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ module CoreTests =
288288

289289
testOkFile.CheckExists()
290290
end
291-
291+
292292
[<Test>]
293293
let span () =
294294

@@ -1820,7 +1820,8 @@ module CoreTests =
18201820
let cfg = testConfig "core/members/set-only-property"
18211821
csc cfg @"%s /target:library /out:cs.dll" cfg.csc_flags ["cs.cs"]
18221822
vbc cfg @"%s /target:library /out:vb.dll" cfg.vbc_flags ["vb.vb"]
1823-
fsc cfg @"%s -r:cs.dll -r:vb.dll -o:fs.exe" cfg.fsc_flags ["fs.fs"]
1823+
fsc cfg @"%s /target:library /out:fs.dll" cfg.fsc_flags ["fs.fs"]
1824+
singleNegTest cfg "calls"
18241825

18251826
#endif
18261827

0 commit comments

Comments
 (0)