Slava Pestov
f901cc72b4
RequirementMachine: Move diagnostics code into a new Diagnostics.cpp
2022-05-10 01:49:56 -04:00
Josh Soref
81d3ad76ac
Spelling ast ( #42463 )
...
* spelling: accessor
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: accommodates
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: argument
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: associated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: availability
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: available
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: belongs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: bookkeeping
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: building
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clazz
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clonable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: closure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: concatenated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conformance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: context
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conversion
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: correspondence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declarations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declared
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: defining
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: delayed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: dependency
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: deployed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: descendants
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnose
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnostic
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: equitable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: evaluation
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: exclusivity
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existential
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: explicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: expressed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: for
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: foreign
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: function
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: identifier
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: implicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: indices
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: information
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: instance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interchangeable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interface
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: introduced
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: invalid
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: kind-in
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: least
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: library
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: location
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: namespace
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: necessary
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: nonexistent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: not
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: number
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: obtains
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: occurs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: opaque
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: overridden
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: parameter
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: precede
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: preceding
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: property
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: protocol
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: qualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recognized
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recursively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: references
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: relaxing
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: represented
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: request
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirements
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: retrieve
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: returned
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfied
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfy
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: siblings
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: simplified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: something
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: source
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specializations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specially
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: statement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: stripped
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: structure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: substitution
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: the
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transform
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transformed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transitively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transparent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: typecheck
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unknown
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unlabeled
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unqualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: whether
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: with
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com >
2022-04-21 12:57:16 -07:00
Slava Pestov
85e73ed021
RequirementMachine: Move a bit of code in computeCompletion() for clarity
2022-04-05 00:04:39 -04:00
Holly Borla
f52593be68
[RequirementMachine] Record the sugared 'Self' type parameter when
...
initializing a RequirementMachine for a written protocol signature.
These generic parameters are used for re-sugaring when computing a
type from a term, so if the recorded 'Self' parameter is canonicalized,
it shows up in diagnostics as 'tau_0_0'.
2022-03-29 18:27:45 -07:00
Holly Borla
caee699560
[RequirementMachine] Mention the type parameter that is the subject of
...
two conflicting requirements in diagnostics where possible.
2022-03-29 18:27:45 -07:00
Holly Borla
deb62f7e3c
[RequirementMachine] Add a helper method to RequirementMachine to compute
...
all requirement diagnostics from the minimal rewrite system.
2022-03-29 18:27:44 -07:00
Slava Pestov
a631d8aa3a
RequirementMachine: Write some comments
2022-03-28 22:16:09 -04:00
Slava Pestov
e2a509c483
RequirementMachine: Freeze machines built from signatures immediately
2022-03-26 00:56:41 -04:00
Slava Pestov
08aab383e8
RequirementMachine: Don't record rewrite loops for protocol signature machines
...
A requirement machine built from existing protocol requirement signatures only
exists to cache those rules and allow them to be inherited by other machines.
Recording loops is unnecessary in this case, since no minimization will be
performed.
2022-03-26 00:56:41 -04:00
Slava Pestov
4d097da73c
RequirementMachine: Re-use requirement machines constructed by minimization for queries
...
Fixes rdar://problem/88135641.
2022-03-26 00:56:41 -04:00
Slava Pestov
3777054c1c
RequirementMachine: Fix dump() output for a recent change
...
Protocol machines now have the 'Self' generic parameter in 'Params', so
we have to change the order of the two 'if' statements.
2022-03-26 00:56:41 -04:00
Slava Pestov
7d0215e6e0
RequirementMachine: Tweak rule limit non-termination heuristic
...
Add the length of the longest *initial* rule to the rule length limit
before comparing.
Fixes https://bugs.swift.org/browse/SR-16024 .
2022-03-25 01:00:49 -04:00
Slava Pestov
ff40f109ca
RequirementMachine: Allow RequirementMachine::isConcreteType() and ::getCanonicalTypeInContext() to be used with protocol connected components
2022-03-22 15:02:06 -04:00
Slava Pestov
4446f2afcf
RequirementMachine: Move some code out of RuleBuilder and into RequirementSignatureRequest
2022-03-22 15:02:06 -04:00
Slava Pestov
6e6c8c29a5
RequirementMachine: Only check local rules against maximum rule limit
...
Completion has a maximum rule limit since the Knuth-Bendix algorithm
is a semi-decision procedure that does not terminate on all inputs.
However, this means that generic signatures which import a large
number of complex protocols can hit the limit even if they are
convergent.
Since imported rules are essentially free, ignore them here, to
avoid having to increase the limit by hand.
Now the default limit is 4000 local rules per requirement machine;
it seems implausible that you would exceed this, but if anyone has
an example we can bump the limit again.
2022-03-16 13:26:37 -04:00
Slava Pestov
ef1636a462
RequirementMachine: Split off RuleBuilder.{cpp,h} from RequirementLowering.{cpp,h}
2022-03-16 12:24:20 -04:00
Slava Pestov
c08601bee9
RequirementMachine: Implement RewriteSystem::getLocalRules()
2022-03-16 00:58:30 -04:00
Slava Pestov
327e7e580b
RequirementMachine: Add importedRules parameter to RewriteSystem::initialize()
2022-03-16 00:58:30 -04:00
Slava Pestov
aaf84ac6c2
RequirementMachine: Implement RequirementMachine::initWithProtocolSignatureRequirements()
2022-03-15 18:34:54 -04:00
Slava Pestov
f3bcc52e6c
RequirementMachine: Rename RequirementMachine::initWithProtocols()
2022-03-15 18:34:54 -04:00
Slava Pestov
564f626f62
RequirementMachine: Rename some RuleBuilder methods for clarity
2022-03-15 18:34:54 -04:00
Slava Pestov
1d8dd94501
RequirementMachine: Refactor RuleBuilder in preparation for rule sharing
2022-03-15 18:34:54 -04:00
Slava Pestov
f5b3d19703
RequirementMachine: Replace hadError() with getErrors() returning an OptionSet
...
This gives us more fine-grained information which will be plumbed
through the various requests.
2022-03-14 12:33:18 -04:00
Holly Borla
7ce6504b93
[RequirementMachine] Avoid passing the requirement error vector through
...
initialization of the rewrite system.
Instead, the rewrite system can determine trivially redundant requirements
by finding structural requirements with no associated rewrite rules.
2022-03-10 13:13:50 -08:00
Holly Borla
4b55c30fad
[RequirementMachine] Instead of recording redundant requirements and other
...
diagnostics in the rewrite system, pass down the 'errors' vector from the
top-level requests.
2022-03-09 18:18:43 -08:00
Holly Borla
b18e815436
[RequirementMachine] Preserve structural requirements during rule construction,
...
and diagnose trivially redundant rules in the rewrite system.
2022-03-09 12:14:58 -08:00
Slava Pestov
ae1ef6d50d
RequirementMachine: Eliminate RequirementMachine::initWithAbstractRequirements()
2022-02-23 00:20:57 -05:00
Slava Pestov
37be2d5dd7
RequirementMachine: Emit a diagnostic note with the offending rewrite rule if completion failed
...
This surfaces an implementation detail, but it might be better
than nothing.
2022-02-07 08:20:59 -05:00
Slava Pestov
0060592b85
RequirementMachine: Add concrete nesting depth check
...
Configured with -requirement-machine-max-concrete-nesting= frontend flag.
2022-02-07 08:20:59 -05:00
Slava Pestov
634ca55764
RequirementMachine: Rework completion limits a bit
...
- Rename StepLimit to MaxRuleCount, DepthLimit to MaxRuleLength
- Rename command line flags to -requirement-machine-max-rule-{count,length}=
- Check limits outside of PropertyMap::buildPropertyMap()
- Simplify the logic in RequirementMachine::computeCompletion()
2022-02-07 08:20:59 -05:00
Slava Pestov
073bb7542e
RequirementMachine: Fixes for debug output
2022-01-27 18:54:03 -05:00
Slava Pestov
10e4ffdfbd
RequirementMachine: Track known protocols in the rewrite system
...
Conditional requirement inference needs to be able to add rewrite rules
from the requirement signatures of hitherto-unseen protocols, so to
help with that, extract out the RuleBuilder's ProtocolMap and move it
into the RewriteSystem.
2022-01-25 00:35:03 -05:00
Slava Pestov
746f4a5a8f
RequirementMachine: Throw out rewrite loops not part of the minimization domain
...
When minimizing a generic signature, we only care about loops
where the basepoint is a generic parameter symbol.
When minimizing protocol requirement signatures in a connected
component, we only care about loops where the basepoint is a
protocol symbol or associated type symbol whose protocol is
part of the connected component.
All other loops can be discarded since they do not encode
redundancies that are relevant to us.
2022-01-05 23:59:46 -05:00
Slava Pestov
7a56ab8c18
RequirementMachine: Mark conflicting rules
...
This isn't quite right, because we really want the longer (more
specific) of the two rules to be conflicting, not the most-recently
added rule.
2021-12-13 18:48:23 -05:00
Slava Pestov
3138020e5d
RequirementMachine: Diagnose non-confluent rewrite systems instead of asserting
...
We assert when building a rewrite system for an existing generic
signature, or in AbstractGenericSignatureRequest, where there is no
source location.
In RequirementSignatureRequest and InferredGenericSignatureRequest
we now produce a diagnostic.
2021-12-10 00:49:46 -05:00
Slava Pestov
34cbfd23a5
RequirementMachine: Don't assert if a rewrite system has unresolved rules
...
This is a source-level error, not an invariant violation. Instead, plumb
a new hadError() flag, which in the future will assert if no diagnostic
was produced.
2021-12-08 00:53:34 -05:00
Slava Pestov
36a7c4c032
RequirementMachine: Move some code around
2021-12-07 15:31:47 -05:00
Slava Pestov
d19b15b66c
RequirementMachine: Introduce Symbol::Kind::ConcreteConformance
2021-12-06 23:04:46 -05:00
Slava Pestov
42c0a28ad7
RequirementMachine: Add RequirementMachine::initWithWrittenRequirements()
2021-11-19 15:48:28 -05:00
Slava Pestov
1c78b0466b
RequirementMachine: Clean up the RequirementMachine::initWith*() methods a bit
2021-11-19 15:48:15 -05:00
Slava Pestov
ff5d0e1d63
RequirementMachine: Split off RuleBuilder into a new RequirementLowering.cpp file
2021-11-12 14:30:46 -05:00
Slava Pestov
d164fb8010
RequirementMachine: Rename RewriteSystemBuilder to RuleBuilder
2021-11-12 14:30:46 -05:00
Slava Pestov
2666449aa6
RequirementMachine: Implement AbstractGenericSignatureRequestRQM
2021-11-12 00:32:43 -05:00
Slava Pestov
952dafad72
RequirementMachine: Preliminary refactoring in preparation for computing top-level generic signatures
2021-11-11 22:39:20 -05:00
Slava Pestov
a4e848f598
RequirementMachine: New way of modeling layout requirement implied by superclass requirement
...
A superclass requirement implies a layout requirement. We don't
want the layout requirement to be present in the minimal
signature, so instead of adding a pair of requirements:
T.[superclass: C<X, Y>] => T
T.[layout: _NativeClass] => T
Add this pair of requirements:
T.[superclass: C<X, Y>] => T
[superclass: C<X, Y>].[layout: _NativeClass] => [superclass: C<X, Y>] [permanent]
Completion then derives the rule as a consequence:
T.[layout: _NativeClass] => T
Since this rule is a consequence of the other two rules, homotopy
reduction will mark it redundant.
2021-11-10 00:18:18 -05:00
Slava Pestov
b7711454a2
RequirementMachine: Rename RewriteSystemBuilder::AssociatedTypeRules => PermanentRules
2021-11-10 00:18:18 -05:00
Robert Widmann
22405cefea
Plumb the "Is Type Sequence" Bit Through the Surface AST
2021-11-08 13:48:30 -08:00
Slava Pestov
5ac83e2819
RequirementMachine: Move buildPropertyMap() from RewriteSystem to PropertyMap
...
Now that the property map stores a reference to the RewriteSystem,
defining the buildPropertyMap() method on PropertyMap feels cleaner,
and allows more of the property map's internals to be private.
2021-11-01 22:51:26 -04:00
Slava Pestov
1057b56395
RequirementMachine: Rename HomotopyGenerator to RewriteLoop
...
Also, stop talking about 2-cells and 3-cells.
2021-10-27 01:28:24 -04:00
Slava Pestov
5689d046d4
RequirementMachine: Always add a rule for the trivial [P].[P] => [P] conformance
...
Completion adds this rule when a same-type requirement equates the Self of P
with some other type parameter conforming to P; one example is something like this:
protocol P {
associatedtype T : P where T.T == Self
}
The initial rewrite system looks like this:
(1) [P].T => [P:T]
(2) [P:T].[P] => [P:T]
(3) [P:T].[P:T] => [P]
Rules (2) and (3) overlap on the term
[P:T].[P:T].[P]
Simplifying the overlapped term with rule (2) produces
[P:T].[P:T]
Which further reduces to
[P]
Simplifying the overlapped term with rule (3) produces
[P].[P]
So we get a new rule
[P].[P] => [P]
This is not a "real" conformance rule, and homotopy reduction wastes work
unraveling it in rewrite loops where this rule occurs. Instead, it's better
to introduce it as a permanent rule that is not subject to homotopy reduction
for every protocol.
2021-10-27 00:34:04 -04:00