<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Pierre,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 17, 2019 at 10:36 PM pierre misse <<a href="mailto:pierre_misse25@msn.com">pierre_misse25@msn.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p><br>
</p>
<div>On 18/12/2019 03:52, Eliot Miranda wrote:<br>
</div>
<blockquote type="cite">
<pre> </pre>
<br>
<fieldset></fieldset>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Hi Pierre,</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Dec 17, 2019 at 9:50 AM pierre misse <<a href="mailto:pierre_misse25@msn.com" target="_blank">pierre_misse25@msn.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>Hi, <br>
</p>
<p>I saw my previous mistake, and corrected this. <br>
This is a sample test, for a very simple inference.<br>
</p>
<p>testReturnFloatConstantNode<br>
| ccg tMethod |<br>
ccg := CCodeGenerator new.<br>
ccg addClass: SlangTypeInferenceTestsClass.<br>
ccg inferTypesForImplicitlyTypedVariablesAndMethods.<br>
tMethod := ccg methodNamed: #returnAFloatConstantNode.<br>
<br>
self assert: tMethod isNotNil.<br>
self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #double.<br>
self assert: tMethod returnType equals: #double</p>
</div>
</blockquote>
<div><br>
</div>
<div> And perhaps have SlangTypeInferenceTestsClass inherit from StackInterpreter or InterpreterPrimitives. That will give you much more context.</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p>I was currently inheriting from interpreterPlugin, but I can indeed switch.</p></div></blockquote><div><br></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">I think you have it right. interpreterPlugin should be fine.</span><br></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium"><br></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
<p>My tests currently were as simple as it gets:</p>
<p>constantNode<br>
Returm constant<br>
return Explicit argument<br>
return Explicit Temporary<br>
return temp assigned by constant.</p>
<p>So it wasn't necessary. <br>
</p>
<p>Only surprising result is the return temp assigned by constant, which loses the type. This seems to be easily improvable in the future if you'd like.</p>
<p>returnTempFloatConstantNode<br>
| t |<br>
t := 1.0.<br>
^ t</p></div></blockquote><div>Its its return type isn't inferred to be #double then that's a bug.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
<p>testReturnTempFloatConstantNode<br>
| ccg tMethod |<br>
ccg := CCodeGenerator new.<br>
ccg addClass: SlangTypeInferenceTestsClass.<br>
ccg inferTypesForImplicitlyTypedVariablesAndMethods.<br>
tMethod := ccg methodNamed: #returnTempFloatConstantNode.<br>
<br>
self assert: tMethod isNotNil.<br>
self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #double.<br>
self assert: (ccg typeFor: tMethod statements first variable in: tMethod) equals: #sqInt.<br>
self assert: tMethod returnType equals: #sqInt.<br></p></div></blockquote><div><br></div><div> Well, t is untyped and it is assigned a double. So I would expect that the inferencer infer the ty[e #double for f. Then it should infer the type #double for returnTempFloatConstantNode since it answers t. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF"><p>
self error "wait what"<br>
</p>
<p><br>
</p>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote">
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p> I need to work on ones with ambiguity.<br>
<br>
<br>
</p>
</div>
</blockquote>
<div> The instability I saw was in getErrorObjectFromPrimFailCode; its two locals clone & errObj are sometimes typed as squint and sometimes as usqInt. Some times numPointerSlotsOf ends up with a return type of usqInt, some times as sqInt. I've recently had
success in another project substituting OrderedDictionary et al for Dictionary. So I'm sure that solutions can be found easily.</div>
<div> </div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p>Thanks for the pointer !<br>
</p>
<p><br>
</p>
<p>Pierre<br></p></div></blockquote><div><br></div><div>Thanks for looking!! It will be great to have tests for this, if only for good documentation. I never had the time, and always look at the diffs of the generated code. But that doesn't mean I don't want these tests. Thank you for your energy!</div></div><div> <br></div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div></div></div>