Skip to content

Conversation

@dduan
Copy link
Contributor

@dduan dduan commented Jul 31, 2016

What's in this pull request?

Implements part of SE-0110. Single argument in closures will not be accepted if
there exists explicit type with a number of arguments that's not 1.

let f: (Int, Int) -> Void = { x in } // this is now an error

Note there's a second part of SE-0110 which could be considered additive,
which says one must add an extra pair of parens to specify a single arugment
type that is a tuple:

let g ((Int, Int)) -> Void = { y in } // y should have type (Int, Int)

This patch does not implement that part.

Edit:

Updates for Foundation, XCTest and SwiftPM:

swiftlang/swift-corelibs-foundation#497
swiftlang/swift-corelibs-xctest#149
swiftlang/swift-package-manager#581

Resolved bug number: (SR-2008, partial)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

A smoke test on macOS does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library only for macOS. Simulator standard libraries and
    device standard libraries are not built.
  3. lldb is not built.
  4. The test and validation-test targets are run only for macOS. The optimized
    version of these tests are not run.

A smoke test on Linux does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library incrementally.
  3. lldb is built incrementally.
  4. The swift test and validation-test targets are run. The optimized version of these
    tests are not run.
  5. lldb is tested.

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

@dduan dduan changed the title [Sema] ban multi-arguments to 1-tuple coercion [Sema] ban multi-arguments to single tuple coercion Jul 31, 2016
@dduan dduan force-pushed the se0110_a-pr branch 3 times, most recently from 746f067 to 9939388 Compare July 31, 2016 17:43
@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2016

@swift-ci test

@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2016

the Foundation build failure has been addressed in this PR: swiftlang/swift-corelibs-foundation#497

@CodaFi
Copy link
Contributor

CodaFi commented Jul 31, 2016

Nice!

AFAICT we can use this patch to sniff out problems in the dependencies first and merge this after they're fixed, right?

@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2016

@CodaFi correct. I've done so with Foundation and XCTest.

@CodaFi
Copy link
Contributor

CodaFi commented Jul 31, 2016

Has this been tested against lldb, swift-playgroundlogger, and swiftpm?

@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2016

@CodaFi ran test on lldb, got this. Are the unexpected success normal?

=============
Issue Details
=============
ERROR: test_dictionary_nsobject_any_object_dsym (lang/swift/variables/dict_nsobj_anyobj/TestSwiftDictionaryNSObjectAnyObject.py)
ERROR: test_dictionary_nsobject_any_object_dwarf (lang/swift/variables/dict_nsobj_anyobj/TestSwiftDictionaryNSObjectAnyObject.py)
ERROR: test_dictionary_nsobject_any_object_gmodules (lang/swift/variables/dict_nsobj_anyobj/TestSwiftDictionaryNSObjectAnyObject.py)
ERROR: test_with_dsym (lang/swift/tagged_pointer/TestSwiftTaggedPointer.py)
ERROR: test_with_dsym (lang/swift/foundation_value_types/notification/TestSwiftFoundationTypeNotification.py)
ERROR: test_with_dsym (lang/swift/po/nested_nsdict/TestSwiftPONestedNSDictionary.py)
ERROR: test_with_dsym (lang/swift/po/sys_types/TestSwiftPOSysTypes.py)
ERROR: test_with_dwarf (lang/swift/foundation_value_types/notification/TestSwiftFoundationTypeNotification.py)
ERROR: test_with_dwarf (lang/swift/po/sys_types/TestSwiftPOSysTypes.py)
ERROR: test_with_dwarf (lang/swift/po/nested_nsdict/TestSwiftPONestedNSDictionary.py)
ERROR: test_with_dwarf (lang/swift/tagged_pointer/TestSwiftTaggedPointer.py)
ERROR: test_with_gmodules (lang/swift/po/sys_types/TestSwiftPOSysTypes.py)
ERROR: test_with_gmodules (lang/swift/foundation_value_types/notification/TestSwiftFoundationTypeNotification.py)
ERROR: test_with_gmodules (lang/swift/po/nested_nsdict/TestSwiftPONestedNSDictionary.py)
ERROR: test_with_gmodules (lang/swift/tagged_pointer/TestSwiftTaggedPointer.py)
UNEXPECTED SUCCESS: testREPL (repl/po_repl_type/TestREPLPOReplType.py)
UNEXPECTED SUCCESS: testREPL (repl/subclassing/TestREPLSubclassing.py)
UNEXPECTED SUCCESS: testREPL (repl/structs/TestREPLStructs.py)
UNEXPECTED SUCCESS: testREPL (repl/breakpoints/TestREPLBreakpoints.py)
UNEXPECTED SUCCESS: test_add_dsym_mid_execution (macosx/add-dsym/TestAddDsymMidExecutionCommand.py)
UNEXPECTED SUCCESS: test_cross_module_extension_dsym (lang/swift/cross_module_extension/TestSwiftCrossModuleExtension.py)
UNEXPECTED SUCCESS: test_cross_module_extension_dwarf (lang/swift/cross_module_extension/TestSwiftCrossModuleExtension.py)
UNEXPECTED SUCCESS: test_cross_module_extension_gmodules (lang/swift/cross_module_extension/TestSwiftCrossModuleExtension.py)
UNEXPECTED SUCCESS: test_dsym (functionalities/exec/TestExec.py)
UNEXPECTED SUCCESS: test_dsym (lang/swift/file_private/TestFilePrivate.py)
UNEXPECTED SUCCESS: test_dsym (functionalities/fat_archives/TestFatArchives.py)
UNEXPECTED SUCCESS: test_dsym (expression_command/timeout/TestCallWithTimeout.py)
UNEXPECTED SUCCESS: test_dwarf (functionalities/fat_archives/TestFatArchives.py)
UNEXPECTED SUCCESS: test_dwarf (functionalities/exec/TestExec.py)
UNEXPECTED SUCCESS: test_dwarf (lang/swift/file_private/TestFilePrivate.py)
UNEXPECTED SUCCESS: test_dwarf (expression_command/timeout/TestCallWithTimeout.py)
UNEXPECTED SUCCESS: test_expr_dsym (lang/objc/modules-inline-functions/TestModulesInlineFunctions.py)
UNEXPECTED SUCCESS: test_expr_dsym (lang/objc/objc-new-syntax/TestObjCNewSyntax.py)
UNEXPECTED SUCCESS: test_expr_dwarf (lang/objc/objc-new-syntax/TestObjCNewSyntax.py)
UNEXPECTED SUCCESS: test_expr_dwarf (lang/objc/modules-inline-functions/TestModulesInlineFunctions.py)
UNEXPECTED SUCCESS: test_expr_gmodules (lang/objc/modules-inline-functions/TestModulesInlineFunctions.py)
UNEXPECTED SUCCESS: test_fd_leak_basic_dsym (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_fd_leak_basic_dwarf (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_fd_leak_basic_gmodules (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_fd_leak_log_dsym (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_fd_leak_log_dwarf (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_fd_leak_log_gmodules (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_fd_leak_multitarget_dsym (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_fd_leak_multitarget_dwarf (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_fd_leak_multitarget_gmodules (functionalities/avoids-fd-leak/TestFdLeak.py)
UNEXPECTED SUCCESS: test_frame_var_after_stop_at_implementation_dsym (lang/objc/real-definition/TestRealDefinition.py)
UNEXPECTED SUCCESS: test_gmodules (lang/swift/file_private/TestFilePrivate.py)
UNEXPECTED SUCCESS: test_gmodules (functionalities/fat_archives/TestFatArchives.py)
UNEXPECTED SUCCESS: test_gmodules (functionalities/exec/TestExec.py)
UNEXPECTED SUCCESS: test_gmodules (expression_command/timeout/TestCallWithTimeout.py)
UNEXPECTED SUCCESS: test_imp_ivar_type (lang/objc/ivar-IMP/TestObjCiVarIMP.py)
UNEXPECTED SUCCESS: test_lldbmi_break_insert_function (tools/lldb-mi/breakpoint/TestMiBreak.py)
UNEXPECTED SUCCESS: test_lldbmi_break_insert_function_pending (tools/lldb-mi/breakpoint/TestMiBreak.py)
UNEXPECTED SUCCESS: test_multiple_debuggers_dsym (api/multiple-debuggers/TestMultipleDebuggers.py)
UNEXPECTED SUCCESS: test_multiple_debuggers_dwarf (api/multiple-debuggers/TestMultipleDebuggers.py)
UNEXPECTED SUCCESS: test_multiple_debuggers_gmodules (api/multiple-debuggers/TestMultipleDebuggers.py)
UNEXPECTED SUCCESS: test_process_attach_with_wrong_arch_dsym (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_process_attach_with_wrong_arch_dwarf (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_process_attach_with_wrong_arch_gmodules (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_process_launch_for_universal_dsym (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_process_launch_for_universal_dwarf (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_process_launch_for_universal_gmodules (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_qRegisterInfo_returns_all_valid_results_debugserver (tools/lldb-server/TestLldbGdbServer.py)
UNEXPECTED SUCCESS: test_qRegisterInfo_returns_one_valid_result_debugserver (tools/lldb-server/TestLldbGdbServer.py)
UNEXPECTED SUCCESS: test_restart_bug_dsym (functionalities/signal/raise/TestRaise.py)
UNEXPECTED SUCCESS: test_restart_bug_dwarf (functionalities/signal/raise/TestRaise.py)
UNEXPECTED SUCCESS: test_restart_bug_gmodules (functionalities/signal/raise/TestRaise.py)
UNEXPECTED SUCCESS: test_sbdebugger_create_target_with_file_and_target_triple_dsym (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_sbdebugger_create_target_with_file_and_target_triple_dwarf (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_sbdebugger_create_target_with_file_and_target_triple_gmodules (macosx/universal/TestUniversal.py)
UNEXPECTED SUCCESS: test_specialized_typedef_from_pch_gmodules (lang/cpp/gmodules/TestWithModuleDebugging.py)
UNEXPECTED SUCCESS: test_swift_private_typealias_dsym (lang/swift/private_typealias/TestSwiftPrivateTypeAlias.py)
UNEXPECTED SUCCESS: test_swift_private_typealias_dwarf (lang/swift/private_typealias/TestSwiftPrivateTypeAlias.py)
UNEXPECTED SUCCESS: test_swift_private_typealias_gmodules (lang/swift/private_typealias/TestSwiftPrivateTypeAlias.py)
UNEXPECTED SUCCESS: test_swift_returns_dsym (lang/swift/return/TestSwiftReturns.py)
UNEXPECTED SUCCESS: test_swift_returns_dwarf (lang/swift/return/TestSwiftReturns.py)
UNEXPECTED SUCCESS: test_swift_returns_gmodules (lang/swift/return/TestSwiftReturns.py)
UNEXPECTED SUCCESS: test_symbol_name_dsym (functionalities/completion/TestCompletion.py)
UNEXPECTED SUCCESS: test_symbol_name_dwarf (functionalities/completion/TestCompletion.py)
UNEXPECTED SUCCESS: test_symbol_name_gmodules (functionalities/completion/TestCompletion.py)
UNEXPECTED SUCCESS: test_top_level_expressions_gmodules (expression_command/top-level/TestTopLevelExprs.py)
UNEXPECTED SUCCESS: test_with_dsym (expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py)
UNEXPECTED SUCCESS: test_with_dwarf (expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py)
UNEXPECTED SUCCESS: test_with_gmodules (expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py)
UNEXPECTED SUCCESS: test_with_python_api_dsym (macosx/safe-to-func-call/TestSafeFuncCalls.py)
UNEXPECTED SUCCESS: test_with_python_api_dsym (macosx/queues/TestQueues.py)
UNEXPECTED SUCCESS: test_with_python_api_dwarf (macosx/safe-to-func-call/TestSafeFuncCalls.py)
UNEXPECTED SUCCESS: test_with_python_api_dwarf (macosx/queues/TestQueues.py)
UNEXPECTED SUCCESS: test_with_python_api_gmodules (macosx/queues/TestQueues.py)
UNEXPECTED SUCCESS: test_with_python_api_gmodules (macosx/safe-to-func-call/TestSafeFuncCalls.py)
UNEXPECTED SUCCESS: test_with_run_command_dsym (functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py)
UNEXPECTED SUCCESS: test_with_run_command_dsym (functionalities/signal/TestSendSignal.py)
UNEXPECTED SUCCESS: test_with_run_command_dwarf (functionalities/signal/TestSendSignal.py)
UNEXPECTED SUCCESS: test_with_run_command_dwarf (functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py)
UNEXPECTED SUCCESS: test_with_run_command_gmodules (functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py)
UNEXPECTED SUCCESS: test_with_run_command_gmodules (functionalities/signal/TestSendSignal.py)

===================
Test Result Summary
===================
Test Methods:       2770
Reruns:               15
Success:            2248
Expected Failure:    136
Failure:               0
Error:                15
Exceptional Exit:      0
Unexpected Success:   81
Skip:                290
Timeout:               0
Expected Timeout:      0

@CodaFi
Copy link
Contributor

CodaFi commented Jul 31, 2016

I'm not sure about the tests, but that it builds is a positive sign WRT this patch.

@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2016

swiftpm changes: swiftlang/swift-package-manager#581

@CodaFi
Copy link
Contributor

CodaFi commented Jul 31, 2016

And a quick rebase please.

@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2016

@CodaFi I tried to test playground logger with build.py but it complains that it foundation is missing. What's the proper way to test it against my swift branch?

Implements part of SE-0110. Single argument in closures will not be accepted if
there exists explicit type with a number of arguments that's not 1.

```swift
let f: (Int, Int) -> Void = { x in } // this is now an error
```

Note there's a second part of SE-0110 which could be considered additive,
which says one must add an extra pair of parens to specify a single arugment
type that is a tuple:

```swift
let g ((Int, Int)) -> Void = { y in } // y should have type (Int, Int)
```

This patch does not implement that part.
@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2016

@CodaFi rebased

@CodaFi
Copy link
Contributor

CodaFi commented Jul 31, 2016

./swift/utils/build-script --playgroundlogger <FURTHER-OPTIONS>

Should do it.

@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2016

@CodaFi Thanks! playgroundlogger is in good shape. No change needed.

@DougGregor
Copy link
Member

The Swift changes look fantastic; thanks for pushing this through!

@dduan
Copy link
Contributor Author

dduan commented Aug 1, 2016

Here's lldb test results ran on master. I think the unexpected success is part of the deal (except the count is different?)

Test Methods:       2770
Reruns:               15
Success:            2278
Expected Failure:    133
Failure:               0
Error:                15
Exceptional Exit:      0
Unexpected Success:   84
Skip:                260
Timeout:               0
Expected Timeout:      0

@CodaFi
Copy link
Contributor

CodaFi commented Aug 1, 2016

You don't have to worry about that here. What I meant was more that there are test cases inside LLDB that run swift code that may need migration. But if the suite builds without hard compiler errors then your job is done.

@dduan dduan changed the title [Sema] ban multi-arguments to single tuple coercion [Sema] ban multi-arguments to tuple coercion Aug 1, 2016
@CodaFi
Copy link
Contributor

CodaFi commented Aug 1, 2016

@swift-ci please smoke test.

@DougGregor
Copy link
Member

@swift-ci please smoke test OS X

@DougGregor
Copy link
Member

the ErrorProtocol issue is something I need to investigate; re-running tests.

@DougGregor DougGregor merged commit f170630 into swiftlang:master Aug 1, 2016
@gottesmm
Copy link
Contributor

gottesmm commented Aug 1, 2016

@DougGregor Can you disable that test using a requires while you investigate?

@dduan dduan deleted the se0110_a-pr branch August 1, 2016 06:42
@DougGregor
Copy link
Member

This caused a pretty serious regression. We no longer type-check this:

let a = [(1, 2), (3, 4)]
a.map { print($0.1) }

@dduan
Copy link
Contributor Author

dduan commented Aug 1, 2016

let a = [(1, 2), (3, 4)]
a.map { print($1) }

would work, no?

@DougGregor
Copy link
Member

It shouldn't work. The element type is (Int, Int), and we should be passing that as a single argument to the closure, not splatting it out to two arguments.

@DougGregor
Copy link
Member

It's probably falling into the "second part of SE-0110" that isn't yet implemented. It might be that we simple cannot separate the two parts.

@dduan
Copy link
Contributor Author

dduan commented Aug 1, 2016

I see. Let's revert this then.

@dduan
Copy link
Contributor Author

dduan commented Aug 1, 2016

I'll work on the second part tonight.

@MnO2 MnO2 mentioned this pull request Aug 8, 2016
1 task
MnO2 added a commit to MnO2/swift that referenced this pull request Aug 14, 2016
This commit built upon the work of Pull Request 3895. Apart from the
work to make the following work

```swift
let f: (Int, Int) -> Void = { x in  } // this is now an error
```

This patch also implement the part 2 mentioned in the swiftlang#3895

```swift
let g: ((Int, Int)) -> Void = { y in  } // y should have type (Int, Int)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants