-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a few F# features: 1. [Attributes](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/attributes). 2. [Computation expressions](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions) (resolves #1459). 3. Class names for type annotations, [casts ](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/casting-and-conversions)(not including `as`), definitions and instancing (resolves #1460). 4. Proper support for ([nullable](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/nullable-operators)) [operators](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/).
- Loading branch information
1 parent
b0d1823
commit 00bfc96
Showing
8 changed files
with
238 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[<Foo>] | ||
[<Bar("bar"); Foo(1, 2)>] | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["annotation", [ | ||
["punctuation", "[<"], | ||
["class-name", "Foo"], | ||
["punctuation", ">]"] | ||
]], | ||
["annotation", [ | ||
["punctuation", "[<"], | ||
["class-name", "Bar"], | ||
["annotation-content", [ | ||
["punctuation", "("], | ||
["string", "\"bar\""], | ||
["punctuation", ")"], | ||
["punctuation", ";"] | ||
]], | ||
["class-name", "Foo"], | ||
["annotation-content", [ | ||
["punctuation", "("], | ||
["number", "1"], | ||
["punctuation", ","], | ||
["number", "2"], | ||
["punctuation", ")"] | ||
]], | ||
["punctuation", ">]"] | ||
]] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for annotations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
let func : HttpFunc = handler (Some >> Task.FromResult) | ||
|
||
type Base1() = | ||
abstract member F : unit -> unit | ||
default u.F() = | ||
printfn "F Base1" | ||
|
||
type Derived1() = | ||
inherit Base1() | ||
override u.F() = | ||
printfn "F Derived1" | ||
|
||
let d1 : Derived1 = Derived1() | ||
|
||
let base1 = d1 :> Base1 | ||
let derived1 = base1 :?> Derived1 | ||
|
||
type PersonName = | ||
| FirstOnly of string | ||
| LastOnly of string | ||
| FirstLast of string * string | ||
|
||
type Shape = | ||
| Rectangle of height : float * width : float | ||
| Circle of radius : float | ||
|
||
type MyInterface = | ||
abstract member Add: int -> int -> int | ||
abstract member Pi : float | ||
|
||
exception Error1 of string | ||
exception Error2 of string * int | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "let"], " func ", | ||
["punctuation", ":"], ["class-name", ["HttpFunc"]], | ||
["operator", "="], " handler ", ["punctuation", "("], | ||
"Some ", ["operator", ">>"], " Task", ["punctuation", "."], "FromResult", | ||
["punctuation", ")"], | ||
|
||
["keyword", "type"], ["class-name", ["Base1"]], ["punctuation", "("], ["punctuation", ")"], ["operator", "="], | ||
["keyword", "abstract"], ["keyword", "member"], " F ", ["punctuation", ":"], | ||
["class-name", [ | ||
"unit ", ["operator", "->"], " unit"] | ||
], | ||
["keyword", "default"], " u", ["punctuation", "."], ["function", "F"], ["punctuation", "("], ["punctuation", ")"], | ||
["operator", "="], "\n printfn ", ["string", "\"F Base1\""], | ||
|
||
["keyword", "type"], ["class-name", ["Derived1"]], ["punctuation", "("], ["punctuation", ")"], ["operator", "="], | ||
["keyword", "inherit"], ["class-name", ["Base1"]], ["punctuation", "("], ["punctuation", ")"], | ||
["keyword", "override"], " u", ["punctuation", "."], ["function", "F"], ["punctuation", "("], ["punctuation", ")"], ["operator", "="], | ||
"\n printfn ", ["string", "\"F Derived1\""], | ||
|
||
["keyword", "let"], " d1 ", ["punctuation", ":"], ["class-name", ["Derived1"]], ["operator", "="], | ||
["function", "Derived1"], ["punctuation", "("], ["punctuation", ")"], | ||
|
||
["keyword", "let"], " base1 ", ["operator", "="], " d1 ", ["operator", ":>"], ["class-name", ["Base1"]], | ||
|
||
["keyword", "let"], " derived1 ", ["operator", "="], " base1 ", ["operator", ":?>"], ["class-name", ["Derived1"]], | ||
|
||
["keyword", "type"], ["class-name", ["PersonName"]], ["operator", "="], | ||
["operator", "|"], " FirstOnly ", ["keyword", "of"], ["class-name", ["string"]], | ||
["operator", "|"], " LastOnly ", ["keyword", "of"], ["class-name", ["string"]], | ||
["operator", "|"], " FirstLast ", ["keyword", "of"], ["class-name", ["string ", ["operator", "*"], " string"]], | ||
|
||
["keyword", "type"], ["class-name", ["Shape"]], ["operator", "="], | ||
["operator", "|"], " Rectangle ", ["keyword", "of"], | ||
" height ", ["punctuation", ":"], ["class-name", ["float"]], ["operator", "*"], | ||
" width ", ["punctuation", ":"], ["class-name", ["float"]], | ||
["operator", "|"], " Circle ", ["keyword", "of"], " radius ", ["punctuation", ":"], ["class-name", ["float"]], | ||
|
||
["keyword", "type"], ["class-name", ["MyInterface"]], ["operator", "="], | ||
["keyword", "abstract"], ["keyword", "member"], " Add", ["punctuation", ":"], | ||
["class-name", ["int ", ["operator", "->"], " int ", ["operator", "->"], " int"]], | ||
["keyword", "abstract"], ["keyword", "member"], " Pi ", ["punctuation", ":"], ["class-name", ["float"]], | ||
|
||
["keyword", "exception"], ["class-name", ["Error1"]], ["keyword", "of"], ["class-name", ["string"]], | ||
|
||
["keyword", "exception"], ["class-name", ["Error2"]], ["keyword", "of"], ["class-name", ["string ", ["operator", "*"], " int"]] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for class-names. |
17 changes: 17 additions & 0 deletions
17
tests/languages/fsharp/computation-expression_feature.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
async {} | ||
task {} | ||
seq {} | ||
foo {} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["computation-expression", "async"], ["punctuation", "{"], ["punctuation", "}"], | ||
["computation-expression", "task"], ["punctuation", "{"], ["punctuation", "}"], | ||
["computation-expression", "seq"], ["punctuation", "{"], ["punctuation", "}"], | ||
["computation-expression", "foo"], ["punctuation", "{"], ["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for computation expressions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
>= <= <> > < = + - * / % | ||
>=? <=? <>? >? <? =? +? -? *? /? %? | ||
?>=? ?<=? ?<>? ?>? ?<? ?=? ?+? ?-? ?*? ?/? ?%? | ||
?>= ?<= ?<> ?> ?< ?= ?+ ?- ?* ?/ ?% | ||
|
||
** | ||
|
||
<- -> | ||
.. | ||
:: | ||
:= | ||
:> :? :?> | ||
<< >> | ||
<<< >>> ~~~ ^^^ &&& ||| | ||
| || | ||
<| <|| <||| | ||
|> ||> |||> | ||
~~ ~- ~+ | ||
|
||
? ^ ! | ||
!= == | ||
& && | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["operator", ">="], ["operator", "<="], ["operator", "<>"], ["operator", ">"], ["operator", "<"], ["operator", "="], ["operator", "+"], ["operator", "-"], ["operator", "*"], ["operator", "/"], ["operator", "%"], | ||
["operator", ">=?"], ["operator", "<=?"], ["operator", "<>?"], ["operator", ">?"], ["operator", "<?"], ["operator", "=?"], ["operator", "+?"], ["operator", "-?"], ["operator", "*?"], ["operator", "/?"], ["operator", "%?"], | ||
["operator", "?>=?"], ["operator", "?<=?"], ["operator", "?<>?"], ["operator", "?>?"], ["operator", "?<?"], ["operator", "?=?"], ["operator", "?+?"], ["operator", "?-?"], ["operator", "?*?"], ["operator", "?/?"], ["operator", "?%?"], | ||
["operator", "?>="], ["operator", "?<="], ["operator", "?<>"], ["operator", "?>"], ["operator", "?<"], ["operator", "?="], ["operator", "?+"], ["operator", "?-"], ["operator", "?*"], ["operator", "?/"], ["operator", "?%"], | ||
|
||
["operator", "**"], | ||
|
||
["operator", "<-"], ["operator", "->"], | ||
["operator", ".."], | ||
["operator", "::"], | ||
["operator", ":="], | ||
["operator", ":>"], ["operator", ":?"], ["operator", ":?>"], | ||
["operator", "<<"], ["operator", ">>"], | ||
["operator", "<<<"], ["operator", ">>>"], ["operator", "~~~"], ["operator", "^^^"], ["operator", "&&&"], ["operator", "|||"], | ||
["operator", "|"], ["operator", "||"], | ||
["operator", "<|"], ["operator", "<||"], ["operator", "<|||"], | ||
["operator", "|>"], ["operator", "||>"], ["operator", "|||>"], | ||
["operator", "~~"], ["operator", "~-"], ["operator", "~+"], | ||
|
||
["operator", "?"], ["operator", "^"], ["operator", "!"], | ||
["operator", "!="], ["operator", "=="], | ||
["operator", "&"], ["operator", "&&"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for operators. |