Misleading error message with 'type'

new topic     » topic index » view thread      » older message » newer message

Hi Rob, hi all,

I got an error message concerning a type, that I didn't understand at
first. Then I found out, that it was because I had included the same
global type twice. It was the following situation:


--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
type1.e
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
global type string (object x)
   object t

   if atom(x) then return 0 end if

   for i = 1 to length(x) do
      t = x[i]
      if not integer(t) or t < 0 or t > #FF then
         return 0
      end if
   end for
   return 1
end type
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=


--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
type2.e
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
global type string (object x)
   object t

   if atom(x) then return 0 end if

   for i = 1 to length(x) do
      t = x[i]
      if not integer(t) or t < 0 or t > #FF then
         return 0
      end if
   end for
   return 1
end type
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=


--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
typedemo.exw
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
include type1.e
include type2.e

procedure show (string source)
   puts(1, source)
end procedure
show("Hi!")
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=


When runnung 'typedemo.exw', Eu 2.3 gave me the following error message:
     C:\temp\typedemo.exw:4
     a type is expected here
     procedure show (string source)
                          ^

That sounds, as if 'string' isn't a type, but it is of course. Because
my program was more complex than the demo shown above, it took me some
time, to find out the real reason.

Wouldn't it be clearer, if Euphoria gives the error message:
    'a namespace qualifier is needed to resolve string'

like it already does, when I call 'string' explicitly, e.g.
print(1, string("Hi!")) ?

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |
 \ /  against HTML in       |  Superstition brings bad luck.
  X   e-mail and news,      |
 / \  and unneeded MIME     |

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu