<font face="Verdana,Arial,Helvetica,sans-serif" size="2"><div>Will/John, </div><div><br></div><div>I can submit a PR to add this test if you think there's value in it. Thanks.<br><font face="Verdana,Arial,Helvetica,sans-serif" size="2"><font><font><div class="socmaildefaultfont" dir="ltr"><div class="socmaildefaultfont" dir="ltr"><div class="socmaildefaultfont" dir="ltr"><div dir="ltr" style="font-style: normal;"><br><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif">Pushkar N Kulkarni,</font></div>
<div dir="ltr" style="font-style: normal;"><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif">IBM Runtimes</font></div><div dir="ltr" style="font-style: normal;"><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif"><br></font></div><div dir="ltr"><font face="serif, Times New Roman, Times, serif"><i>Simplicity is prerequisite for reliability - Edsger W. Dijkstra</i></font></div>
<div dir="ltr" style="font-style: normal; font-size: 10.5pt; font-family: Arial;"><br></div></div></div></div></font></font></font></div><br><br><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2" color="#000000"><font color="#990099">-----Will Stanton <<a href="mailto:willstanton1@yahoo.com" target="_blank">willstanton1@yahoo.com</a>> wrote: -----</font><div class="iNotesHistory" style="padding-left:5px;"><div style="padding-right:0px;padding-left:5px;border-left:solid black 2px;">To: John McCall <<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>><br>From: Will Stanton <<a href="mailto:willstanton1@yahoo.com" target="_blank">willstanton1@yahoo.com</a>><br>Date: 05/13/2017 12:04AM<br>Cc: Pushkar N Kulkarni <<a href="mailto:pushkar.nk@in.ibm.com" target="_blank">pushkar.nk@in.ibm.com</a>>, swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>><br>Subject: Re: [swift-dev] Property modification not taking effect<br><br><div><font face="Courier New,Courier,monospace" size="3">I am a bit curious about Pushkar’s test case; perhaps it should be added as a test?<br><br>The SIL emitted then vs ~today looked very similar, so I was thinking the issue might be in IRGen.<br>Scanning there, looks like this cured the problem:<br>@shajrawi <a href="https://github.com/apple/swift/pull/9452">https://github.com/apple/swift/pull/9452</a> Disable large types irgen pass<br><br>The property change happens when the pass is disabled, but before f9861fe6fcd9d797653f62a0b0c4142e719eecf1, the change does not happen:<br>before => ready(test.TState(drain: test.Drain.foo("wow")))<br>after => ready(test.TState(drain: test.Drain.foo("wow")))<br><br>The `newValue` access in willSet apparently ‘alters’ it to the old value.<br><a href="https://bugs.swift.org/browse/SR-4852">https://bugs.swift.org/browse/SR-4852</a><br><br>Regards,<br>Will Stanton<br><br>> On May 10, 2017, at 1:08 PM, John McCall via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>> wrote:<br>> <br>>> On May 10, 2017, at 11:06 AM, Pushkar N Kulkarni <<a href="mailto:pushkar.nk@in.ibm.com" target="_blank">pushkar.nk@in.ibm.com</a>> wrote:<br>>> The issue is seen with the 05-09 dev snapshot. However after updating the repos today, I no longer see it! <br>>> <br>>> Looks like one of yesterday's commits (which did not go into 05-09) fixed it. I am closing the JIRA report. Thanks!<br>> <br>> Okay, glad we managed to fix it; thanks.<br>> <br>> John.<br>> <br>>> <br>>> Pushkar N Kulkarni,<br>>> IBM Runtimes<br>>> <br>>> Simplicity is prerequisite for reliability - Edsger W. Dijkstra<br>>> <br>>> <br>>> <br>>> <a href="mailto:-----swift-dev-bounces@swift.org" target="_blank">-----swift-dev-bounces@swift.org</a> wrote: -----<br>>> To: John McCall <<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>><br>>> From: Pushkar N Kulkarni via swift-dev <br>>> Sent by: <a href="mailto:swift-dev-bounces@swift.org" target="_blank">swift-dev-bounces@swift.org</a><br>>> Date: 05/10/2017 06:00PM<br>>> Cc: swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>><br>>> Subject: Re: [swift-dev] Property modification not taking effect<br>>> <br>>> Thanks John. This is the JIRA bug report: <a href="https://bugs.swift.org/browse/SR-4852">https://bugs.swift.org/browse/SR-4852</a><br>>> <br>>> I was able to write a small test case that shows the regression:<br>>> <br>>> enum State {<br>>> case ready(TState)<br>>> case inProgress(TState)<br>>> <br>>> var isPaused: Bool {<br>>> switch self {<br>>> case .ready: return false<br>>> case .inProgress: return false<br>>> }<br>>> }<br>>> }<br>>> <br>>> enum Drain {<br>>> case foo(String)<br>>> case bar(Int, String)<br>>> }<br>>> <br>>> struct TState {<br>>> let drain: Drain<br>>> }<br>>> <br>>> class Task {<br>>> var state = State.ready(TState(drain: .foo("wow"))) { <br>>> willSet {<br>>> if newValue.isPaused { }<br>>> }<br>>> }<br>>> <br>>> func resume() {<br>>> if case .ready(let tState) = state {<br>>> print("before => \(state)")<br>>> state = .inProgress(tState) //doesn't take effect<br>>> print("after => \(state)")<br>>> }<br>>> }<br>>> } <br>>> <br>>> //main<br>>> Task().resume()<br>>> <br>>> Output with the latest master:<br>>> before => ready(Test.TState(drain: Test.Drain.foo("wow")))<br>>> after => ready(Test.TState(drain: Test.Drain.foo("wow")))<br>>> <br>>> <br>>> Expected output (and with the 04-24 snapshot as well):<br>>> before => ready(Test.TState(drain: Test.Drain.foo("wow")))<br>>> after => inProgress(Test.TState(drain: Test.Drain.foo("wow")))<br>>> <br>>> <br>>> Pushkar N Kulkarni,<br>>> IBM Runtimes<br>>> <br>>> Simplicity is prerequisite for reliability - Edsger W. Dijkstra<br>>> <br>>> <br>>> <br>>> <a href="mailto:-----rjmccall@apple.com" target="_blank">-----rjmccall@apple.com</a> wrote: -----<br>>> To: Pushkar N Kulkarni <<a href="mailto:pushkar.nk@in.ibm.com" target="_blank">pushkar.nk@in.ibm.com</a>><br>>> From: John McCall <br>>> Sent by: <a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a><br>>> Date: 05/10/2017 04:19AM<br>>> Cc: swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>><br>>> Subject: Re: [swift-dev] Property modification not taking effect<br>>> <br>>>> On May 9, 2017, at 3:07 PM, Pushkar N Kulkarni via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>> wrote:<br>>>> In the process of debugging a bunch of consistent failures in TestFoundation/TestNSURLSession, I came across a weird problem symptom in this line of code.<br>>>> <br>>>> internalState = .transferInProgress(transferState)<br>>>> <br>>>> I had a suspicion that the above modification is not taking effect, since, only based on this change the didSet observer for the `internalState` property triggers data transfers using libcurl. So, I simply printed the property before and after the assignment. <br>>>> <br>>>> print("before => \(internalState)")<br>>>> internalState = .transferInProgress(transferState)<br>>>> print("after => \(internalState)")<br>>>> <br>>>> Surprisingly, I don't see any change in the property value:<br>>>> before => transferReady(Foundation.URLSessionTask._TransferState(... <redacted> ...))<br>>>> after => transferReady(Foundation.URLSessionTask._TransferState(... <redacted> ...))<br>>>> <br>>>> When I switched back to the "swift-DEVELOPMENT-SNAPSHOT-2017-04-24-a" tag on all the repos (except swift-corelibs-foundation), I do not see this problem. I see:<br>>>> before => transferReady(Foundation.URLSessionTask._TransferState(... <redacted> ...))<br>>>> after => transferInProgress(Foundation.URLSessionTask._TransferState(... <redacted> ...))<br>>>> <br>>>> To put it in simple terms, the modification doesn't seem to be taking effect with the current HEAD. <br>>>> <br>>>> I haven't been able to isolate this problem in an independent test case. However, anybody who wants to reproduce it can simply run TestFoundation after enabling the URLSession tests (which have been disabled for now) in TestFoundation/main.swift. <br>>>> <br>>>> I did compare the `-emit-ir` outputs from the passing and failing levels. There seems to be a clear difference in the way we store the new value of this property. But given my limited exposure to debugging Swift compiler issues, I wasn't able to progress further. <br>>>> <br>>>> Can someone help us here please? Thanks. <br>>> <br>>> That sounds like a serious bug; please file it in JIRA.<br>>> <br>>> John.<br><br><br></font></div></div></div></font></font><BR>