smelly code in input.c

Anthony Clayden <[email protected]> Mon, 14 Jun 2021 22:47:39 +1200
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <CABU_mxiHr21qYw9_jWgw5=s0dXp8vNf_1TFp0ZpGyHtis_qDAg@mail.gmail.com>
--===============7702017632235290013==
Content-Type: multipart/alternative; boundary="000000000000a59adc05c4b79680"

--000000000000a59adc05c4b79680
Content-Type: text/plain; charset="UTF-8"

(I can't say for sure I have a bug, because I don't grok the code well
enough to figure out how to make something go wrong, but ...)

In /src/input.c line 1714
https://github.com/FranklinChen/hugs98-plus-Sep2006/blob/master/src/input.c#L1714
,

>     if (c0=='.' && isIn(c0,(SMALL|LARGE|SYMBOL))) {

It looks wrong to be testing `c0` twice, that test will always come out
False. (Or if '.' counts as a SYMBOL, then always True.) I guess the second
test should be lookahead `isIn(c1, ...)`. That follows the code pattern
nearby above line 1688, and especially 1698.

I think it'll mean the compiler won't handle multi-qualified names like
`Mod1.Sub2.Subsub3.Foo`. Whereas `Prelude.True` (just a single qualifier)
is ok.

Can anyone confirm my suspicion and/or suggest a definitive test?

(Reason for asking: I'm trying to persuade Hugs to differentiate
tight-binding dot as an operator vs space-surrounded dot as function
composition. In particular so I can write `record.label` as field access.
I'd also like to write `record.#label` as a TRex field access.)

AntC

--000000000000a59adc05c4b79680
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr">(I can&#39;t s=
ay for sure I have a bug, because I don&#39;t grok the code well enough to =
figure out how to make something go wrong, but ...)<div><br></div><div>In /=
src/input.c line 1714=C2=A0<a href=3D"https://github.com/FranklinChen/hugs9=
8-plus-Sep2006/blob/master/src/input.c#L1714" target=3D"_blank">https://git=
hub.com/FranklinChen/hugs98-plus-Sep2006/blob/master/src/input.c#L1714</a>,=
</div><div><br></div><div>&gt;=C2=A0 =C2=A0=C2=A0<span style=3D"color:rgb(3=
6,41,46);font-family:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,Consol=
as,&quot;Liberation Mono&quot;,Menlo,monospace;font-size:12px;white-space:p=
re-wrap;background-color:rgb(255,251,221)">   </span><span style=3D"box-siz=
ing:border-box;font-family:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,=
Consolas,&quot;Liberation Mono&quot;,Menlo,monospace;font-size:12px;white-s=
pace:pre-wrap">if</span><span style=3D"color:rgb(36,41,46);font-family:ui-m=
onospace,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Liberation Mono&=
quot;,Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:=
rgb(255,251,221)"> (c0=3D=3D</span><span style=3D"box-sizing:border-box;fon=
t-family:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Lib=
eration Mono&quot;,Menlo,monospace;font-size:12px;white-space:pre-wrap"><sp=
an style=3D"box-sizing:border-box">&#39;</span>.<span style=3D"box-sizing:b=
order-box">&#39;</span></span><span style=3D"color:rgb(36,41,46);font-famil=
y:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Liberation=
 Mono&quot;,Menlo,monospace;font-size:12px;white-space:pre-wrap;background-=
color:rgb(255,251,221)"> &amp;&amp; </span><span style=3D"box-sizing:border=
-box;font-family:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&=
quot;Liberation Mono&quot;,Menlo,monospace;font-size:12px;white-space:pre-w=
rap">isIn</span><span style=3D"color:rgb(36,41,46);font-family:ui-monospace=
,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Liberation Mono&quot;,Me=
nlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(255,=
251,221)">(c0,(SMALL|LARGE|SYMBOL))) {</span></div><div><span style=3D"colo=
r:rgb(36,41,46);font-family:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;=
,Consolas,&quot;Liberation Mono&quot;,Menlo,monospace;font-size:12px;white-=
space:pre-wrap;background-color:rgb(255,251,221)"><br></span></div><div><sp=
an style=3D"font-family:Arial,Helvetica,sans-serif">It looks wrong to be te=
sting `c0` twice, that test will always come out False. (Or if &#39;.&#39; =
counts as a SYMBOL, then always True.) I guess the second test should be lo=
okahead `isIn(c1, ...)`. That follows=C2=A0the code pattern nearby above li=
ne 1688, and especially 1698.</span></div><div><span style=3D"font-family:A=
rial,Helvetica,sans-serif"><br></span></div><div><span style=3D"font-family=
:Arial,Helvetica,sans-serif">I think it&#39;ll mean the compiler won&#39;t =
handle multi-qualified names like `Mod1.Sub2.Subsub3.Foo`. Whereas `Prelude=
.True` (just a single qualifier) is ok.</span></div><div><span style=3D"fon=
t-family:Arial,Helvetica,sans-serif"><br></span></div><div><span style=3D"f=
ont-family:Arial,Helvetica,sans-serif">Can anyone confirm my suspicion and/=
or suggest a definitive test?</span></div><div><span style=3D"font-family:A=
rial,Helvetica,sans-serif"><br></span></div><div><span style=3D"font-family=
:Arial,Helvetica,sans-serif">(Reason for asking: I&#39;m trying to persuade=
 Hugs to differentiate tight-binding dot as an operator vs space-surrounded=
 dot as function composition. In particular so I can write `record.label` a=
s field access. I&#39;d also like to write `record.#label` as a TRex field =
access.)</span></div><div><span style=3D"font-family:Arial,Helvetica,sans-s=
erif"><br></span></div><div><span style=3D"font-family:Arial,Helvetica,sans=
-serif">AntC</span></div><div><span style=3D"font-family:Arial,Helvetica,sa=
ns-serif"><br></span></div><div><span style=3D"font-family:Arial,Helvetica,=
sans-serif"><br></span></div><div><span style=3D"font-family:Arial,Helvetic=
a,sans-serif"><br></span></div><div><br></div></div>
</div></div>

--000000000000a59adc05c4b79680--

--===============7702017632235290013==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSHVncy1CdWdz
IG1haWxpbmcgbGlzdApIdWdzLUJ1Z3NAaGFza2VsbC5vcmcKaHR0cDovL21haWwuaGFza2VsbC5v
cmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL2h1Z3MtYnVncw==

--===============7702017632235290013==--