Tracked within Apple by <rdar://problem/36754225> Swift CI:
parse_stdlib.sil tests failing with vtable verification. The error is
an assertion failure that we haven't traced back to its cause yet:
Assertion failed: (EntriesSZ == VTableEntryCache.size() && "Cache
size is not equal to true number of VTable entries"), function
verify, file /Users/buildnode/jenkins/workspace/
oss-swift-package-osx/swift/lib/SIL/SILVerifier.cpp, line 4747.
Being part of the type of a private declaration isn't sufficient,
because that could be used for the inferred type of a non-private
variable/constant/property.
Also, introduce a new kind of dependency test that shows both that a
file A changes its interface based on a change in another file B, and
that the swiftdeps output for file A includes the dependency on file B
as cascading.
https://bugs.swift.org/browse/SR-6149
The sharding of this test buys us nothing, because it was only sharding
the AST verifier, which is an insignificant portion of the runtime
(and memory usage) of this test. Given that the test takes ~2m30s to run
and consumes > 2GB memory, having 17 copies of it running is a problem.
The test was originally disabled but to timeouts that were supposedly caused by the new integer protocols. A few improvements have been implemented in the compiler as well as in the standard library since them, so it might no longer be a problem.
introduce a common superclass, SILNode.
This is in preparation for allowing instructions to have multiple
results. It is also a somewhat more elegant representation for
instructions that have zero results. Instructions that are known
to have exactly one result inherit from a class, SingleValueInstruction,
that subclasses both ValueBase and SILInstruction. Some care must be
taken when working with SILNode pointers and testing for equality;
please see the comment on SILNode for more information.
A number of SIL passes needed to be updated in order to handle this
new distinction between SIL values and SIL instructions.
Note that the SIL parser is now stricter about not trying to assign
a result value from an instruction (like 'return' or 'strong_retain')
that does not produce any.
I don't have reduced test cases. The original test cases
were a series of frontend invocations in -parse-stdlib
mode.
While the original bugs seem to have been fixed, while
verifying I found a few places where we weren't checking
for null decls property in the ASTContext.
Probably not too useful to check this in, but I don't see it
causing any harm, either.
All we need to store is whether the SILDeclRef directly
references the declaration, or if it references a curry
thunk, and we already have an isCurried bit for that.
With more recent versions of LLVM (e.g., used with master-next) the
argument of REQUIRES is parsed as an expression. Do not use "rdar"
URLS for these since it confuses lit.
Previously we had more ad hoc logic that tried to decide if it was
worth desugaring a type based on its structure. Now we instead look
for a typealias that might actually benefit from desugaring, and if
we don't find one we won't show the 'aka' note.
The existence of a shared_external function in itself is not
an error; it just means we deserialized a witness table or
vtable but did not need to deserialize a thunk.
However, a direct reference to such a function is an error,
because we should have deserialized the body in that case.
This fixes a crasher, but the SIL crashers are kind of silly
because the SIL parser does not try at all not to crash on
invalid input.
Also, add a third [serializable] state for functions whose bodies we
*can* serialize, but only do so if they're referenced from another
serialized function.
This will be used for bodies synthesized for imported definitions,
such as init(rawValue:), etc, and various thunks, but for now this
change is NFC.
Currently if destination is unresolved instead of trying to re-typecheck
it again and diagnose structural problems which led to such outcome, it
gets completely ignored in favor of trying to type-check source without
contextual type. That leads to missed diagnostic opportunities, which
results in problems on AST verification and SIL generation stages, and
generally missleading errors e.g. `.x = 0`.
Resolves: SR-3506.
- In functions called from resolveType(), consistently
use a Type() return value to indicate 'unsatisfied
dependency', and ErrorType to indicate failure.
- Plumb the unsatisfiedDependency callback through the
resolution of the arguments of BoundGenericTypes, and
also pass down the options.
- Before doing a conformance check on the argument of a
BoundGenericType, kick off a TypeCheckSuperclass request
if the type in question is a class. This ensures we don't
recurse through NominalTypeDecl::prepareConformanceTable(),
which wants to see a class with a valid superclass.
- The ResolveTypeOfDecl request was assuming that
the request was satisfied after calling validateDecl().
This is not the case when the ITC is invoked from a
recursive call to validateDecl(), hack this up by returning
*true* from isResolveTypeDeclSatisfied(); otherwise we
assert in satisfy(), and we can't make forward progress
in this case anyway.
- Fix a bug in cycle breaking; it seems if we don't invoke
the cycle break callback on all pending requests, we end
up looping forever in an outer call to satisfy().
- Remove unused TR_GlobalTypeAlias option.
Use a syntax that declares the layout's generic parameters and fields,
followed by the generic arguments to apply to the layout:
{ var Int, let String } // A concrete box layout with a mutable Int
// and immutable String field
<T, U> { var T, let U } <Int, String> // A generic box layout,
// applied to Int and String
// arguments
When a generic parameter list fails to parse, we don't call
DeclContext::setGenericParams(), even though the generic
parameters are still available for name lookup.
This causes various crashes, which this patch fixes by
mapping the generic parameters to ErrorTypes.
See <rdar://problem/24060338> Identify problems with textual SIL and fix them
This was never working, but does seem to have recently been fixed on OSX.
It's still failing on Linux:
SIL verification failed: vtable entry for #_AnySequenceBox._prefix!1 must be ABI-compatible
Different conventions for parameter 0
@convention(method) <τ_0_0> (Int, @guaranteed _AnySequenceBox<τ_0_0>) -> @owned _AnySequenceBox<τ_0_0>
@convention(method) <τ_0_0> (@owned @callee_owned (@in τ_0_0) -> (Bool, @error Error), @guaranteed _AnySequenceBox<τ_0_0>) -> (@owned _AnySequenceBox<τ_0_0>, @error Error)
In function:
Use tok::NUM_TOKENS instead. tok::unknown can easily appear in source code.
For instance `skipUntil(tok::eof)` did not work as expected, because that was
`skipUntil(tok::eof, tok::unknown)` hence does stop at error tokens such as
`0xG` (invalid hex number literal).
Revert 2abc92bbb5, since that was
accidental side-effect of 45118037cc.
Forward references are not allowed actually.
Stack trace:
```
<stdin>:3:9: error: expected '{' in class
class a 4{sil_vtable a
^
<stdin>:3:10: error: statement cannot begin with a closure expression
class a 4{sil_vtable a
^
<stdin>:3:10: note: explicitly discard the result of the closure by assigning to '_'
class a 4{sil_vtable a
^
_ =
<stdin>:3:11: error: expected '}' at end of closure
class a 4{sil_vtable a
^
<stdin>:3:10: note: to match this opening '{'
class a 4{sil_vtable a
^
<stdin>:3:10: error: expressions are not allowed at the top level
class a 4{sil_vtable a
^
<stdin>:3:10: error: braced block of statements is an unused closure
class a 4{sil_vtable a
^
<stdin>:3:10: error: expression resolves to an unused function
class a 4{sil_vtable a
^
sil-opt: /path/to/swift/include/swift/Parse/Parser.h:388: swift::SourceLoc swift::Parser::consumeToken(swift::tok): Assertion `Tok.is(K) && "Consuming wrong token kind"' failed.
8 sil-opt 0x0000000000b23aa3 swift::Parser::parseTopLevel() + 739
9 sil-opt 0x0000000000ad68e0 swift::parseIntoSourceFile(swift::SourceFile&, unsigned int, bool*, swift::SILParserState*, swift::PersistentParserState*, swift::DelayedParsingCallbacks*) + 208
10 sil-opt 0x0000000000801933 swift::CompilerInstance::performSema() + 3315
11 sil-opt 0x00000000007e84bc main + 1852
Stack dump:
0. Program arguments: sil-opt -enable-sil-verify-all
1. With parser at source location: <stdin>:3:23
```