<font face="Verdana,Arial,Helvetica,sans-serif" size="2"><div>Will/John,&nbsp;</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 &lt;<a href="mailto:willstanton1@yahoo.com" target="_blank">willstanton1@yahoo.com</a>&gt; 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 &lt;<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>&gt;<br>From: Will Stanton &lt;<a href="mailto:willstanton1@yahoo.com" target="_blank">willstanton1@yahoo.com</a>&gt;<br>Date: 05/13/2017 12:04AM<br>Cc: Pushkar N Kulkarni &lt;<a href="mailto:pushkar.nk@in.ibm.com" target="_blank">pushkar.nk@in.ibm.com</a>&gt;, swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt;<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>&nbsp;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 =&gt; ready(test.TState(drain: test.Drain.foo("wow")))<br>after =&gt; 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>&gt; On May 10, 2017, at 1:08 PM, John McCall via swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt; wrote:<br>&gt; <br>&gt;&gt; On May 10, 2017, at 11:06 AM, Pushkar N Kulkarni &lt;<a href="mailto:pushkar.nk@in.ibm.com" target="_blank">pushkar.nk@in.ibm.com</a>&gt; wrote:<br>&gt;&gt; The issue is seen with the 05-09 dev snapshot. However after updating the repos today, I no longer see it! <br>&gt;&gt; <br>&gt;&gt; Looks like one of yesterday's commits (which did not go into 05-09) &nbsp;fixed it. I am closing the JIRA report. Thanks!<br>&gt; <br>&gt; Okay, glad we managed to fix it; thanks.<br>&gt; <br>&gt; John.<br>&gt; <br>&gt;&gt; <br>&gt;&gt; Pushkar N Kulkarni,<br>&gt;&gt; IBM Runtimes<br>&gt;&gt; <br>&gt;&gt; Simplicity is prerequisite for reliability - Edsger W. Dijkstra<br>&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; <a href="mailto:-----swift-dev-bounces@swift.org" target="_blank">-----swift-dev-bounces@swift.org</a> wrote: -----<br>&gt;&gt; To: John McCall &lt;<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>&gt;<br>&gt;&gt; From: Pushkar N Kulkarni via swift-dev <br>&gt;&gt; Sent by: <a href="mailto:swift-dev-bounces@swift.org" target="_blank">swift-dev-bounces@swift.org</a><br>&gt;&gt; Date: 05/10/2017 06:00PM<br>&gt;&gt; Cc: swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt;<br>&gt;&gt; Subject: Re: [swift-dev] Property modification not taking effect<br>&gt;&gt; <br>&gt;&gt; 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>&gt;&gt; <br>&gt;&gt; I was able to write a small test case that shows the regression:<br>&gt;&gt; <br>&gt;&gt; enum State {<br>&gt;&gt; &nbsp; &nbsp; case ready(TState)<br>&gt;&gt; &nbsp; &nbsp; case inProgress(TState)<br>&gt;&gt; <br>&gt;&gt; &nbsp; &nbsp; var isPaused: Bool {<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; switch self {<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; case .ready: return false<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; case .inProgress: return false<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&gt;&gt; &nbsp; &nbsp; }<br>&gt;&gt; }<br>&gt;&gt; <br>&gt;&gt; enum Drain {<br>&gt;&gt; &nbsp; &nbsp; case foo(String)<br>&gt;&gt; &nbsp; &nbsp; case bar(Int, String)<br>&gt;&gt; }<br>&gt;&gt; <br>&gt;&gt; struct TState {<br>&gt;&gt; &nbsp; &nbsp; let drain: Drain<br>&gt;&gt; }<br>&gt;&gt; <br>&gt;&gt; class Task {<br>&gt;&gt; &nbsp; &nbsp; var state = State.ready(TState(drain: .foo("wow"))) { <br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; willSet {<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if newValue.isPaused { }<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&gt;&gt; &nbsp; &nbsp; }<br>&gt;&gt; <br>&gt;&gt; &nbsp; &nbsp; func resume() {<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; if case .ready(let tState) = state {<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print("before =&gt; \(state)")<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state = .inProgress(tState) //doesn't take effect<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print("after =&gt; \(state)")<br>&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&gt;&gt; &nbsp; &nbsp; }<br>&gt;&gt; } &nbsp; &nbsp;<br>&gt;&gt; <br>&gt;&gt; //main<br>&gt;&gt; Task().resume()<br>&gt;&gt; <br>&gt;&gt; Output with the latest master:<br>&gt;&gt; before =&gt; ready(Test.TState(drain: Test.Drain.foo("wow")))<br>&gt;&gt; after =&gt; ready(Test.TState(drain: Test.Drain.foo("wow")))<br>&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; Expected output (and with the 04-24 snapshot as well):<br>&gt;&gt; before =&gt; ready(Test.TState(drain: Test.Drain.foo("wow")))<br>&gt;&gt; after =&gt; inProgress(Test.TState(drain: Test.Drain.foo("wow")))<br>&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; Pushkar N Kulkarni,<br>&gt;&gt; IBM Runtimes<br>&gt;&gt; <br>&gt;&gt; Simplicity is prerequisite for reliability - Edsger W. Dijkstra<br>&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; <a href="mailto:-----rjmccall@apple.com" target="_blank">-----rjmccall@apple.com</a> wrote: -----<br>&gt;&gt; To: Pushkar N Kulkarni &lt;<a href="mailto:pushkar.nk@in.ibm.com" target="_blank">pushkar.nk@in.ibm.com</a>&gt;<br>&gt;&gt; From: John McCall <br>&gt;&gt; Sent by: <a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a><br>&gt;&gt; Date: 05/10/2017 04:19AM<br>&gt;&gt; Cc: swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt;<br>&gt;&gt; Subject: Re: [swift-dev] Property modification not taking effect<br>&gt;&gt; <br>&gt;&gt;&gt; On May 9, 2017, at 3:07 PM, Pushkar N Kulkarni via swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt; wrote:<br>&gt;&gt;&gt; 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>&gt;&gt;&gt; <br>&gt;&gt;&gt; internalState = .transferInProgress(transferState)<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; 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>&gt;&gt;&gt; <br>&gt;&gt;&gt; print("before =&gt; \(internalState)")<br>&gt;&gt;&gt; internalState = .transferInProgress(transferState)<br>&gt;&gt;&gt; print("after =&gt; \(internalState)")<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; Surprisingly, I don't see any change in the property value:<br>&gt;&gt;&gt; before =&gt; transferReady(Foundation.URLSessionTask._TransferState(... &lt;redacted&gt; ...))<br>&gt;&gt;&gt; after &nbsp;=&gt; transferReady(Foundation.URLSessionTask._TransferState(... &lt;redacted&gt; ...))<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; 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>&gt;&gt;&gt; before =&gt; transferReady(Foundation.URLSessionTask._TransferState(... &lt;redacted&gt; ...))<br>&gt;&gt;&gt; after &nbsp;=&gt; transferInProgress(Foundation.URLSessionTask._TransferState(... &lt;redacted&gt; ...))<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; To put it in simple terms, the modification doesn't seem to be taking effect with the current HEAD. <br>&gt;&gt;&gt; <br>&gt;&gt;&gt; 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>&gt;&gt;&gt; <br>&gt;&gt;&gt; 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. &nbsp;<br>&gt;&gt;&gt; &nbsp;<br>&gt;&gt;&gt; Can someone help us here please? Thanks. <br>&gt;&gt; <br>&gt;&gt; That sounds like a serious bug; please file it in JIRA.<br>&gt;&gt; <br>&gt;&gt; John.<br><br><br></font></div></div></div></font></font><BR>