Commit Graph

104 Commits

Author SHA1 Message Date
Saleem Abdulrasool
d0048ccc61 stdlib: android does not support FP80
Correct the maximal floating point width.  Although technically, Android
could support FP128 on AArch64, Swift does not currently support FP128.
For now, ensure that we use FP64 on Android.
2020-04-13 12:23:26 -07:00
kelvin13
ed2552a694 fix merge conflict and update caseless stdlib enums to use synthesized Comparable 2020-01-02 18:40:50 -06:00
Paul Hudson
06f82a53b5 Replaced the majority of ' : ' with ': '. 2019-07-18 20:46:07 +01:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Harlan Haskins
615b8be990 [stdlib] Silence warnings related to uninhabited types
PR #20528 was merged yesterday, which inserts an `unreachable` in
functions with uninhabited parameters. Unfortunately this means any
statement in the function body, even ones that themselves are
never-returning or don't have any executable code, cause the warning.

Silence the warnings by deleting the bodies of these functions.
2018-11-30 13:50:16 -08:00
Mark Lacey
b7626d7ccf [stdlib] Update Policy.swift with designated types for logical and range operators. 2018-11-17 20:18:28 -08:00
Mark Lacey
d7cf830842 [ConstraintSystem] Add Array as a designated type for + and +=.
Also add overloads for these operators to an extension of Array.

This allows us to typecheck array concatenation quickly with
designated type support enabled and the remaining type checker hacks
disabled.
2018-11-15 21:42:33 -08:00
Richard Wei
44c2f7761a Implement SE-0233 AdditiveArithmetic 2018-11-07 19:43:13 -08:00
John McCall
abdba1d3f4 Change the integer-literal type from Int2048 to IntLiteral.
Part of SR-290.
2018-10-31 23:14:58 -04:00
Mark Lacey
b158651119 [ConstraintSystem] Extend solver support for designated types for operators.
Have the constraint solver consider multiple designated types for an
operator. We currently consider the overloads from each in turn,
stopping as soon as we have a solution. As a result, we can still end
up with exponential type checking in some cases if an operator has
more than a single designated type. This still allows us to reduce the
base of that exponent, though, which makes it possible to increase the
number of expressions we can type check successfully in practice.
2018-10-15 23:51:43 -07:00
Mark Lacey
9b7f9b2ec2 [stdlib] Update Policy.swift to use designated protocols for operators.
Also enable the parsing of these with
-enable-operator-designated-protocols in the stdlib build.

The constraint solver support to make use of these is not yet in-tree.
and will probably land with a different command-line option to enable
it, so that we can continue to have parsing support enabled in-tree
while the constraint solver support is iteratively improved.
2018-10-03 10:24:12 -07:00
Doug Gregor
61d1ab9ea1 [Standard library] Reintroduce operator declarations for pre/postfix ++/--.
The removal of these operator declarations caused a source
compatibility break, because some Swift code is defining prefix or
postfix ++/-- functions without defining the ++ or --
operators. Reinstate the operator declarations in the standard
library... but not any of the functions.

Fixes rdar://problem/43258773.
2018-08-24 13:45:50 -07:00
Matt Diephouse
f0cb64dec3 Conform Never to Error, Equatable, Comparable, and Hashable (#16857) 2018-07-18 15:41:14 -07:00
Mark Lacey
8ee52763f0 Remove the '++' and '--' operators.
We still had unavailable versions of these for floating-point types
only. We shouldn't need to keep these around, and can instead just
emit a helpful diagnostic for anyone that attempts to use them.

Unfortunately I don't see any way for the diagnostic to produce an
actual fix-it, so it just suggests '+= 1' or '-= 1' without actually
producing a fix.
2018-07-12 15:46:57 -07:00
Ben Cohen
a6952decab [stdlib] Remove inlineable annotation from transparent functions (#17800)
* Remove inlineable annotation from transparent functions
2018-07-07 08:47:02 -07:00
Ben Cohen
a4230ab2ad [stdlib] Update stdlib to 4.0 and reorganize compatibility shims (#17580)
* Update stdlib to 4.0 and move all compatibility shims into a dedicated source file
2018-06-29 06:26:52 -07:00
Nate Cook
653a4d89d2 [stdlib] Revise documentation comments
- Clarify RawValue requirement for OptionSet
- Make Bool counterexample more clearly an error
- Add clarifying note about unsafe arithmetic methods
- Add/refine complexity docs for sequence/collection
- Remove docs from obsoleted symbols
- Standardize on unicode.org for links about Unicode
- More complexity annotations
- Expand dictionary defaulted subscript docs
- Fix error in Dictionary.init(minimumCapacity:) docs
- Improve accuracy of prime number listing
2018-06-14 19:19:19 -05:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Jordan Rose
9034ba617b Ban @_fixed_layout on enums in favor of @_frozen
In theory there could be a "fixed-layout" enum that's not exhaustive
but promises not to add any more cases with payloads, but we don't
need that distinction today.

(Note that @objc enums are still "fixed-layout" in the actual sense of
"having a compile-time known layout". There's just no special way to
spell that.)
2018-03-20 14:49:10 -07:00
bruno-rocha-movile
9750689210 [stdlib][SR-4818] Add overflow assignment operators 2018-03-10 13:55:45 -03:00
Max Moiseev
bfddc4a763 [stdlib] Make default implementations of bitwise operators as obsoleted
Fixes: https://bugs.swift.org/browse/SR-7019

Prior to Swift 4 and the new integers, there was a protocol called
`BitwiseOperations`. It was deemed not needed with the introduction of
the integer protocols. But, for backward compatibility, it was left in
the standard library as `_BitwiseOperations` with a conditionally
available typealias `BitwiseOperations`. That protocol declares only the
"non-muating" operators, the mutating ones (i.e. `|=` and friends) are
defined as free functions. They are implemented in terms of
`_BitwiseOperations` protocol requirements, which is reasonable.

In the new integer protocols we established a
convention to provide default implementations for non-mutating functions
in terms of mutating ones (exactly the opposite of a much earlier
decision made for `BitwiseOperations`). So now, when you define a type
that conforms to the `FixedWidthInteger`, even though both mutating and
non-mutating bitwise operations are required, the default implementation
of `|` comes from extension FixedWidthInteger, and the default
implementation of `|=` comes from the _BitwiseOperations free functions.
And they are mutually recursive. Hence the crash.

This commit breaks the recursion by marking default implementations for
`|` etc. in `_BitwiseOperations` obsoleted from Swift 4.1 onward. The
test is also added to make sure the change helps.
2018-02-20 16:31:20 -08:00
Nate Cook
0b62b0608d [stdlib] Doc revisions
- Add missing docs & parameter lists
- Remove deprecated `characters` usage in examples
- Revise documentation for Mirror and CVarArg
- Revise documentation for swap(_:_:)
- Various typo and grammar fixes
2017-11-07 11:11:23 -06:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Xiaodi Wu
a4ac677bae Put new standard operators in the right place 2017-09-02 12:02:12 -05:00
Xi Ge
82d9ec4634 [stdlib] Attaching document comment properly to AnyObject. NFC (#10817) 2017-07-07 16:01:47 -07:00
Robert Widmann
0cf1b52452 Treat Cygwin as a separate OS
Cygwin is considered a distinct target with a distinct ABI, environment
conditions, and data types.  Though the goal of the project is
native Windows integration with UNIX-likes, that is not compatible with
the idea that the platform can be ignored as Win-like enough to have the
existing os(Windows) condition apply.
2017-06-28 13:31:05 -07:00
Nate Cook
b7af9bfe83 [stdlib] Remove SeeAlso tags 2017-06-13 11:23:51 -05:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
Ben Cohen
38903764df Revert "Revert "[stdlib] One-sided ranges and RangeExpression (#8710)"" 2017-04-30 16:47:23 -07:00
Arnold Schwaighofer
7d5d63eaf8 Revert "[stdlib] One-sided ranges and RangeExpression (#8710)"
This reverts commit 946b776e37.
2017-04-30 15:51:16 -07:00
Ben Cohen
946b776e37 [stdlib] One-sided ranges and RangeExpression (#8710)
* One-sided ranges and RangeExpression

* Remove redundant ClosedRange methods from String

* Fix up brittle tests

* Account for Substring update

* XFAIL range diagnostics on Linux
2017-04-28 12:59:04 -07:00
Maxim Moiseev
0f142591e3 [stdlib] Making BitwiseOperations typealias public 2017-04-24 15:32:14 -07:00
Dave Abrahams
d3ad565b33 [stdlib] Clean up warnings 2017-04-20 14:08:57 -07:00
Max Moiseev
d128ed42b0 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-19 14:16:32 -08:00
Han Sangjin
a8dec7fa43 [stdlib] Fixed for Cygwin
- CYGWIN symbol is used to distinguish Cygwin environment from other OS
  and other environment in Windows.
- Added windows and windowsCygnus to OSVersion in StdlibUnittest
2017-01-17 02:31:16 +09:00
Max Moiseev
27889c6376 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-06 15:54:44 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Max Moiseev
baf392eda4 Deprecating the BitwiseOperations protocol in favor of FixedWidthInteger 2016-12-02 16:59:32 -08:00
Rintaro Ishizaki
f6668a263d [stdlib] Adjust precedence of '->' operator
Precedence of '->' was too low.
`_ = () -> Int` was folded as:
  (arrow
    (assign
      (discard_assignment_expr)
      (tuple_expr))
    (unresolved_declref))
It should be:
  (assign
    (discard_assignment_expr)
    (arrow
      (tuple_expr)
      (unresolved_declref)))
2016-11-24 10:46:36 +09:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Nate Cook
bd6025f463 [stdlib] Various documentation fixes
- Fix incorrect type in Float(_:String) examples
- Expand discussions for ExpressibleBy_Literal protocols
- Add notes about non-escaping unsafe pointers from closures
- Add note about isEmpty to Collection.count discussions
- Describe imported `Bool` types
- Clean up some floating point discussions
- Provide some additional operator documentation
- Revise documentation for CVarArg functions
- Fix incorrect Set method parameter descriptions
- Clarify array bridging behavior
- Add collection subscript complexity notes
2016-11-11 11:23:49 -06:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Nate Cook
559092bbf2 [stdlib] Revise stdlib documentation comments
- Expand pre-example explanations
- Update documentation for SE-0118
- Removing remaining 'iff' usage
- Revise Array discussion
- Fix formIndex(_:offsetBy) parameter formatting
- Improve index/formIndex(_:offsetBy:(limitedBy:)?) discussion
- Update Quick Look discussions
- Fixes grammar inconsistencies
- Adds parameter / return documentation
- Adds and expands on examples
- Revises AnyObject discussion for new `id` bridging rules
- Revise readLine, print, and assertion functions
- Add missing docs to String index-moving methods
2016-08-05 16:07:46 -05:00
Robert Widmann
14dc86cf15 Polish off uses of dynamicType in codebase 2016-07-29 16:58:40 -07:00
Nate Cook
58fb4ef9c5 [stdlib] Clean up various documentation issues (#3804)
* [stdlib] Clean up some documentation formatting

* [stdlib] Update example code for SE-0103

* [stdlib] Fix UnsafeBufferPointer documentation typo

* [stdlib] Collection documentation cleanup

* [stdlib] Fix String.init?(_:UTF16View) description

* [stdlib] Documentation fixes for SE-0091

* [stdlib] Add param info for String(repeating:count:)
2016-07-28 11:25:38 -07:00
John McCall
c8c41b385c Implement SE-0077: precedence group declarations.
What I've implemented here deviates from the current proposal text
in the following ways:

- I had to introduce a FunctionArrowPrecedence to capture the parsing
  of -> in expression contexts.

- I found it convenient to continue to model the assignment property
  explicitly.

- The comparison and casting operators have historically been
  non-associative; I have chosen to preserve that, since I don't
  think this proposal intended to change it.

- This uses the precedence group names and higherThan/lowerThan
  as agreed in discussion.
2016-07-26 14:04:57 -07:00
practicalswift
7e89679404 [gardening] Fix recently introduced typos. 2016-07-24 22:32:40 +02:00
Patrick Pijnappel
2728bd0145 [stdlib] Standardize function signature spacing 2016-07-23 11:51:32 +10:00
Slava Pestov
6ff02a9fe2 AST/SIL: Add a new Never type, and a TypeBase::isNever() check
Mostly NFC, this is just plumbing for the next patch.
Note that isNever() returns true for any uninhabited
enum.

It should be generalized so that stuff like (Never, Int)
is also known to be uninhabited, or even to support
generic substitutions that yield uninhabited types,
but for now I really see no reason to go that far, and
the current check for an enum with no cases seems
perfectly adequate.
2016-07-22 14:55:45 -07:00
Joe
7b9e5de7b7 [SE-0095] simplifyTypeExpr for composition expressions
Also adds:
- Any is caught before doing an unconstrained lookup, and the
protocol<> type is emitted
- composition expressions can be handled by
`PreCheckExpression::simplifyTypeExpr` to so you can do lookups like (P
& Q).self
- Fixits corrected & new tests added
- Typeref lowering cases should have been optional
- This fixes a failing test case.
2016-07-19 12:01:37 -07:00