Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e55115

Browse files
committed
Fix fordotnet#78 - allow space characters in active pattern case identifiers (changeset 1282327)
1 parent1936874 commit9e55115

File tree

5 files changed

+72
-15
lines changed

5 files changed

+72
-15
lines changed

‎src/fsharp/PrettyNaming.fs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,13 @@ module internal Microsoft.FSharp.Compiler.PrettyNaming
393393
(nm.IndexOf'|'=0)&&
394394
nm.Length>=3&&
395395
(nm.LastIndexOf'|'= nm.Length-1)&&
396-
(letcore= nm.Substring(1,nm.Length-2)
397-
// no operator characters except '|'
398-
core|> String.forall(fun c-> c='|'||not(opCharDict.ContainsKey c))&&
399-
// at least one non-operator character
400-
core|> String.exists(fun c->not(opCharDict.ContainsKey c)))
396+
(
397+
letcore= nm.Substring(1, nm.Length-2)
398+
// no operator characters except '|' and ' '
399+
core|> String.forall(fun c-> c='|'|| c=' '||not(opCharDict.ContainsKey c))&&
400+
// at least one non-operator or space character
401+
core|> String.exists(fun c-> c=' '||not(opCharDict.ContainsKey c))
402+
)
401403

402404
//IsActivePatternName "|+|" = false
403405
//IsActivePatternName "|ABC|" = true

‎tests/fsharp/typecheck/sigs/build.bat‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ call %~d0%~p0..\..\..\config.bat
88
call ..\..\single-neg-test.bat neg91
99
@if ERRORLEVEL1goto Error
1010

11+
"%FSC%"%fsc_flags% --target:exe -o:pos16.exe pos16.fs
12+
@if ERRORLEVEL1goto Error
13+
14+
"%PEVERIFY%" pos16.exe
15+
@if ERRORLEVEL1goto Error
16+
17+
pos16.exe
18+
@if ERRORLEVEL1goto Error
19+
1120
"%FSC%"%fsc_flags% --target:exe -o:pos15.exe pos15.fs
1221
@if ERRORLEVEL1goto Error
1322

‎tests/fsharp/typecheck/sigs/neg16.bsl‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,30 @@ neg16.fs(78,11,78,31): typecheck error FS0001: This expression was expected to h
6161
but here has type
6262
string
6363

64-
neg16.fs(86,15,86,16): typecheck errorFS0823: The'VolatileField' attribute may only be used on 'let' bindingsin classes
64+
neg16.fs(85,8,85,18): typecheck errorFS0039: Thepattern discriminator 'FooA++' isnot defined
6565

66-
neg16.fs(89,11,89,14): typecheck errorFS0823: The'VolatileField' attribute may only be used on 'let' bindingsin classes
66+
neg16.fs(87,50,87,54): typecheck errorFS0039: Thevalueor constructor 'OneA' isnot defined
6767

68-
neg16.fs(89,11,89,14): typecheck errorFS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
68+
neg16.fs(87,60,87,69): typecheck errorFS0039: The valueor constructor 'TwoA+' isnot defined
6969

70-
neg16.fs(92,7,92,9): typecheck errorFS0823: The'VolatileField' attribute may only be used on 'let' bindingsin classes
70+
neg16.fs(90,8,90,18): typecheck errorFS0039: Thepattern discriminator 'FooB++' isnot defined
7171

72-
neg16.fs(92,7,92,9): typecheck errorFS0879: Volatile fields mustbemarked 'mutable'and cannot be thread-static
72+
neg16.fs(97,15,97,16): typecheck errorFS0823: The 'VolatileField' attribute may onlybeused on 'let' bindingsin classes
7373

74-
neg16.fs(108,17,108,24): typecheck error FS0823: The 'VolatileField' attribute may only be used on 'let' bindingsin classes
74+
neg16.fs(100,11,100,14): typecheck error FS0823: The 'VolatileField' attribute may only be used on 'let' bindingsin classes
7575

76-
neg16.fs(96,16,96,19): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
76+
neg16.fs(100,11,100,14): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
7777

78-
neg16.fs(99,16,99,20): typecheck errorFS0879: Volatile fields mustbemarked 'mutable'and cannot be thread-static
78+
neg16.fs(103,7,103,9): typecheck errorFS0823: The 'VolatileField' attribute may onlybeused on 'let' bindingsin classes
7979

80-
neg16.fs(102,9,102,11): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
80+
neg16.fs(103,7,103,9): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
8181

82-
neg16.fs(105,9,105,13): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
82+
neg16.fs(119,17,119,24): typecheck error FS0823: The 'VolatileField' attribute may only be used on 'let' bindingsin classes
83+
84+
neg16.fs(107,16,107,19): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
85+
86+
neg16.fs(110,16,110,20): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
87+
88+
neg16.fs(113,9,113,11): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static
89+
90+
neg16.fs(116,9,116,13): typecheck error FS0879: Volatile fields must be marked 'mutable'and cannot be thread-static

‎tests/fsharp/typecheck/sigs/neg16.fs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ module ActivePatternSanityCHeckTests3 = begin
7979

8080
end
8181

82+
moduleActivePatternIllegalPatterns=begin
83+
84+
let(|``FooA++``|)(x:int)= x
85+
let(``FooA++``(x))=10
86+
87+
let(|OneA|``TwoA+``|)(x:int)=if x=0then OneAelse``TwoA+``
88+
89+
let(|``FooB++``|_|)(x:int)=if x=0then Some(x)else None
90+
let(``FooB++``(x))=10
91+
92+
end
8293

8394
moduleVolatileFieldSanityChecks=begin
8495

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
modulePos16
2+
3+
// verify backticked active pattern cases
4+
5+
// single case
6+
let(|``A B C``|)(x:int)= x*2
7+
let(``A B C``(k))=5
8+
if k<>10then exit1
9+
10+
// partial case
11+
let(|``Alpha Beta ``|_|)(x:int)=
12+
if x=0then Some()else None
13+
14+
match0,1with
15+
|(_,``Alpha Beta``)-> exit1
16+
|(``Alpha Beta``,_)->()
17+
|_-> exit1
18+
19+
// multi-case
20+
let(|``Charlie Delta``|Echo|``Fox Trot``|)(x:int)=
21+
if x=0then``Charlie Delta``
22+
elif x=1then Echo
23+
else``Fox Trot``
24+
25+
match0,1,2with
26+
|``Charlie Delta``,Echo,``Fox Trot``->()
27+
|_-> exit1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp