eo icon indicating copy to clipboard operation
eo copied to clipboard

Unused aliases false positive

Open OlesiaSub opened this issue 3 years ago • 3 comments

This code

+alias org.eolang.io.stdout
+alias org.eolang.txt.sprintf
+alias org.eolang.txt.sprintf

[] > main
  stdout > @
    sprintf
      "I am %d years old"
      21

should not be executed because of duplicated aliases.

However, compiler will fail with the following mistakes: image

It says that both sprintf aliases are not used, even though one of them is.

OlesiaSub avatar Aug 10 '22 07:08 OlesiaSub

@mximp definitely a bug, please help

yegor256 avatar Aug 10 '22 10:08 yegor256

@EugeneDar would you try to fix it?

mximp avatar Aug 12 '22 06:08 mximp

@mximp sure, I'll try to do it

EugeneDar avatar Aug 12 '22 09:08 EugeneDar

@yegor256 @mximp what type of error should we get in this case? Probably only the alias "..." is dublicated?

EugeneDar avatar Aug 12 '22 19:08 EugeneDar

@EugeneDar That's right. In this case there should be single alias duplicated error.

mximp avatar Aug 15 '22 07:08 mximp

@yegor256 @mximp @Graur The problem is that when converting from EO to XMIR, we get duplication, as you can see on the fifth line below.

   <objects>
      <o abstract="" line="5" name="main" pos="0">
         <o line="5" name="x" pos="1"/>
         <o base="org.eolang.io.stdout" line="6" name="@" pos="2">
            <o base="org.eolang.txt.sprintf org.eolang.txt.sprintf"
               line="7"
               pos="4">
               <o base="string" data="string" line="8" pos="6">Hello</o>
            </o>
         </o>
      </o>
   </objects>

In that case, is this XMIR correct?

EugeneDar avatar Aug 16 '22 15:08 EugeneDar

The XMIR above is derived from this code

  +alias org.eolang.io.stdout
  +alias org.eolang.txt.sprintf
  +alias org.eolang.txt.sprintf

  [x] > main
    stdout > @
      sprintf
        "Hello"

EugeneDar avatar Aug 16 '22 15:08 EugeneDar

@EugeneDar this is definitely a broken XMIR

yegor256 avatar Aug 16 '22 15:08 yegor256

@EugeneDar What is your question?

mximp avatar Aug 16 '22 16:08 mximp

@mximp I wanted to know if this XMIR is correct in order to know if the translator to XMIR needs to be fixed or if the error search needs to be fixed.

EugeneDar avatar Aug 16 '22 16:08 EugeneDar

@OlesiaSub this problem fixed there https://github.com/objectionary/eo/pull/1041

EugeneDar avatar Aug 18 '22 10:08 EugeneDar

@EugeneDar thanks!

OlesiaSub avatar Aug 18 '22 10:08 OlesiaSub