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

Feature/nullness - parsing of constraints #15753

Merged
merged 39 commits into from
Sep 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
884caac
basic tests created for syntaxtree
T-Gro Aug 4, 2023
9912ae7
appType BAR NULL -> rule added
T-Gro Aug 4, 2023
6ab42e0
IIII am still failing...
T-Gro Aug 4, 2023
2aea264
more failing cases added
T-Gro Aug 4, 2023
173d4f6
typar not supports null -> new rule
T-Gro Aug 4, 2023
6d1c8ad
put syntaxtree tests back to doing all of them
T-Gro Aug 4, 2023
de03a17
now it works
T-Gro Aug 4, 2023
a377b20
remove unnecessary leftovers
T-Gro Aug 4, 2023
7099498
regression for Choice type (not yet fixed) caused by precedence rules
T-Gro Aug 22, 2023
b6e4d2c
in unions, "appType | null" has to be put in ()
T-Gro Aug 23, 2023
247b8a9
Fix regression for DU declarations with named fields
T-Gro Aug 23, 2023
5fcc891
heavily annotated expression - test case
T-Gro Aug 23, 2023
2b68ea1
precedence for fsharp.core style of SynUnionCaseKind.FullType
T-Gro Aug 23, 2023
29f5e2f
one more time...
T-Gro Aug 23, 2023
9d06c72
Few more precedence rules, FSharp.Core only feature still failing
T-Gro Aug 25, 2023
1dece40
xx
T-Gro Aug 28, 2023
2c7c76a
regressions
T-Gro Aug 28, 2023
df356d7
better error recovery merged in from a fresher base
T-Gro Aug 28, 2023
14f835a
separated definition
T-Gro Aug 28, 2023
dbf1332
still not there
T-Gro Aug 29, 2023
80e69d3
BAR_NULL created in LexFilter
T-Gro Aug 31, 2023
f6620b7
Renaming to BAR_RIGHT_BEFORE_NULL, because that is what it is (NULL c…
T-Gro Aug 31, 2023
f9c9052
removing spaces
T-Gro Aug 31, 2023
9b66213
baseline adjustments for recovery - it still recovers
T-Gro Sep 1, 2023
beb8fbc
Cases for using type annotation for an expression after a match clause
T-Gro Sep 1, 2023
f639590
BAR precedence
T-Gro Sep 1, 2023
55174f7
try fix "as vs. or" regression in pattern matching
T-Gro Sep 4, 2023
f65d0b6
AS vs BAR precedence for pattern matching
T-Gro Sep 4, 2023
f495c01
Merge branch 'feature/nullness' into feature/nullness_parsing_constra…
T-Gro Sep 4, 2023
a38ead9
merge resolution
T-Gro Sep 4, 2023
79346a7
fix inline flags
T-Gro Sep 4, 2023
b0fa981
Fix IntegerOverflow
T-Gro Sep 7, 2023
c0830da
renamed to BAR_JUST_BEFORE_NULL
T-Gro Sep 7, 2023
f1aa4aa
missing rename
T-Gro Sep 7, 2023
af24968
Merge branch 'main' into feature/nullness_parsing_constraints
T-Gro Sep 7, 2023
dfe4cc3
Few more conflict resolutions
T-Gro Sep 7, 2023
d24043f
Syntaxtree tests updated
T-Gro Sep 8, 2023
267e7a2
Fixing tests
T-Gro Sep 8, 2023
788be51
Merge branch 'feature/nullness' into feature/nullness_parsing_constra…
T-Gro Sep 8, 2023
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
Prev Previous commit
Next Next commit
in unions, "appType | null" has to be put in ()
  • Loading branch information
T-Gro committed Aug 23, 2023
commit b6e4d2c3887d48580b52dccd535a844462edb335
4 changes: 2 additions & 2 deletions src/Compiler/SyntaxTree/LexFilter.fs
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ let infixTokenLength token =
| COLON_GREATER -> 2
| COLON_COLON -> 2
| COLON_EQUALS -> 2
| BAR_BAR -> 2
| BAR_BAR -> 2
| AMP_AMP -> 2
| INFIX_BAR_OP d
| INFIX_AMP_OP d
@@ -2417,7 +2417,7 @@ type LexFilterImpl (
pool.Return tokenTup
hwTokenFetch useBlockRule

| TRY, _ ->
| TRY, _ ->
if debug then dprintf "Try, pushing CtxtTry(%a)\n" outputPos tokenStartPos
pushCtxt tokenTup (CtxtTry tokenStartPos)
// The ideal spec would be to push a begin/end block pair here, but we can only do that
10 changes: 5 additions & 5 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
@@ -85,8 +85,8 @@ let parse_error_rich = Some(fun (ctxt: ParseErrorContext<_>) ->
%token QMARK QMARK_QMARK DOT COLON COLON_COLON COLON_GREATER COLON_QMARK_GREATER COLON_QMARK COLON_EQUALS SEMICOLON
%token SEMICOLON_SEMICOLON LARROW EQUALS LBRACK LBRACK_BAR LBRACE_BAR LBRACK_LESS
%token BAR_RBRACK BAR_RBRACE UNDERSCORE
%token BAR RBRACK RBRACE_COMING_SOON RBRACE_IS_HERE MINUS DOLLAR
%token GREATER_RBRACK STRUCT SIG NULL
%token NULL BAR RBRACK RBRACE_COMING_SOON RBRACE_IS_HERE MINUS DOLLAR
%token GREATER_RBRACK STRUCT SIG
%token STATIC MEMBER CLASS ABSTRACT OVERRIDE DEFAULT CONSTRUCTOR INHERIT
%token EXTERN VOID PUBLIC PRIVATE INTERNAL GLOBAL
%token MAYBENULL__ NOTNULL__ WITHNULL__
@@ -374,7 +374,7 @@ let parse_error_rich = Some(fun (ctxt: ParseErrorContext<_>) ->
%left HIGH_PRECEDENCE_TYAPP

%nonassoc prec_interaction_empty
%right multiple_union_cases
%nonassoc multiple_union_cases

%%

@@ -2634,7 +2634,7 @@ unionTypeRepr:
{ [$1] }

barAndgrabXmlDoc:
| BAR
| BAR %prec multiple_union_cases
{ let mBar = rhs parseState 1
grabXmlDoc(parseState, [], 1), mBar }

@@ -2763,7 +2763,7 @@ unionCaseReprElement:
let mWhole = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc
mkSynNamedField ($1, $3, xmlDoc, mWhole) }

| appType
| appType %prec IDENT
{ let xmlDoc = grabXmlDoc(parseState, [], 1)
mkSynAnonField ($1, xmlDoc) }

Original file line number Diff line number Diff line change
@@ -1 +1 @@
type DU = MyCase of string | null
type DU = MyCase of (string | null)
18 changes: 10 additions & 8 deletions tests/service/data/SyntaxTree/Nullness/DuCaseStringOrNull.fs.bsl
Original file line number Diff line number Diff line change
@@ -18,18 +18,20 @@ ImplFile
Fields
[SynField
([], false, None,
WithNull
(LongIdent
(SynLongIdent ([string], [], [None])),
false, (1,20--1,33)), false,
Paren
(WithNull
(LongIdent
(SynLongIdent ([string], [], [None])),
false, (1,21--1,34)), (1,20--1,35)),
false,
PreXmlDoc ((1,20), FSharp.Compiler.Xml.XmlDocCollector),
None, (1,20--1,33), { LeadingKeyword = None })],
None, (1,20--1,35), { LeadingKeyword = None })],
PreXmlDoc ((1,10), FSharp.Compiler.Xml.XmlDocCollector),
None, (1,10--1,33), { BarRange = None })],
(1,10--1,33)), (1,10--1,33)), [], None, (1,5--1,33),
None, (1,10--1,35), { BarRange = None })],
(1,10--1,35)), (1,10--1,35)), [], None, (1,5--1,35),
{ LeadingKeyword = Type (1,0--1,4)
EqualsRange = Some (1,8--1,9)
WithKeyword = None })], (1,0--1,33))], PreXmlDocEmpty, [],
WithKeyword = None })], (1,0--1,35))], PreXmlDocEmpty, [],
None, (1,0--2,0), { LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
type DU = MyCase of string | null * int
type DU = MyCase of (string | null) * int
22 changes: 12 additions & 10 deletions tests/service/data/SyntaxTree/Nullness/DuCaseTuplePrecedence.fs.bsl
Original file line number Diff line number Diff line change
@@ -18,24 +18,26 @@ ImplFile
Fields
[SynField
([], false, None,
WithNull
(LongIdent
(SynLongIdent ([string], [], [None])),
false, (1,20--1,33)), false,
Paren
(WithNull
(LongIdent
(SynLongIdent ([string], [], [None])),
false, (1,21--1,34)), (1,20--1,35)),
false,
PreXmlDoc ((1,20), FSharp.Compiler.Xml.XmlDocCollector),
None, (1,20--1,33), { LeadingKeyword = None });
None, (1,20--1,35), { LeadingKeyword = None });
SynField
([], false, None,
LongIdent (SynLongIdent ([int], [], [None])),
false,
PreXmlDoc ((1,36), FSharp.Compiler.Xml.XmlDocCollector),
None, (1,36--1,39), { LeadingKeyword = None })],
PreXmlDoc ((1,38), FSharp.Compiler.Xml.XmlDocCollector),
None, (1,38--1,41), { LeadingKeyword = None })],
PreXmlDoc ((1,10), FSharp.Compiler.Xml.XmlDocCollector),
None, (1,10--1,39), { BarRange = None })],
(1,10--1,39)), (1,10--1,39)), [], None, (1,5--1,39),
None, (1,10--1,41), { BarRange = None })],
(1,10--1,41)), (1,10--1,41)), [], None, (1,5--1,41),
{ LeadingKeyword = Type (1,0--1,4)
EqualsRange = Some (1,8--1,9)
WithKeyword = None })], (1,0--1,39))], PreXmlDocEmpty, [],
WithKeyword = None })], (1,0--1,41))], PreXmlDocEmpty, [],
None, (1,0--2,0), { LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
49 changes: 43 additions & 6 deletions tests/service/data/SyntaxTree/Nullness/RegressionChoiceType.fs.bsl
Original file line number Diff line number Diff line change
@@ -3,10 +3,47 @@ ImplFile
("/root/Nullness/RegressionChoiceType.fs", false,
QualifiedNameOfFile RegressionChoiceType, [], [],
[SynModuleOrNamespace
([RegressionChoiceType], false, AnonModule, [], PreXmlDocEmpty, [],
None, (8,0--8,0), { LeadingKeyword = None })], (true, true),
([RegressionChoiceType], false, AnonModule,
[Types
([SynTypeDefn
(SynComponentInfo
([],
Some
(PostfixList
([SynTyparDecl ([], SynTypar (T1, None, false));
SynTyparDecl ([], SynTypar (T2, None, false))], [],
(1,13--1,22))), [], [MyChoice],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector),
true, None, (1,5--1,13)),
Simple
(Union
(None,
[SynUnionCase
([], SynIdent (MyChoice, None),
Fields
[SynField
([], false, None,
Var (SynTypar (T1, None, false), (4,16--4,19)),
false,
PreXmlDoc ((4,16), FSharp.Compiler.Xml.XmlDocCollector),
None, (4,16--4,19), { LeadingKeyword = None })],
PreXmlDoc ((4,2), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,2--4,19), { BarRange = Some (4,2--4,3) });
SynUnionCase
([], SynIdent (MyChoice, None),
Fields
[SynField
([], false, None,
Var (SynTypar (T2, None, false), (7,16--7,19)),
false,
PreXmlDoc ((7,16), FSharp.Compiler.Xml.XmlDocCollector),
None, (7,16--7,19), { LeadingKeyword = None })],
PreXmlDoc ((7,2), FSharp.Compiler.Xml.XmlDocCollector),
None, (6,2--7,19), { BarRange = Some (7,2--7,3) })],
(3,2--7,19)), (3,2--7,19)), [], None, (1,5--7,19),
{ LeadingKeyword = Type (1,0--1,4)
EqualsRange = Some (1,23--1,24)
WithKeyword = None })], (1,0--7,19))], PreXmlDocEmpty, [],
None, (1,0--8,0), { LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
CodeComments = [LineComment (6,2--6,46)] }, set []))

(7,4)-(7,12) parse error Unexpected identifier in union case. Expected 'null' or other token.
(6,2)-(6,46) parse info XML comment is not placed on a valid language element.
CodeComments = [] }, set []))