I have the following code in some e file:
<'
package my_package;
struct packet {
foo() is {
print "Hello";
};
};
'>
And my top file imports several files, including this one, and at some point it calls the foo() method.
Now, by mistake I added this code:
struct packet {};
in some other file (I just forgot that I already had a struct called “packet”), which is imported by top before the above file.
Strangely, when I tried to load the top file, I got this error:
*** Error: 'p' (of type main::packet) does not have 'foo()' method.
at line 9 in top.e
p.foo();
But why didn’t it fail already on the file that defines foo()?
It has a struct declaration for packet, but packet was already (mistakenly) declared in an earlier file, so why didn’t it give a duplicate type name error? Is it allowed to have two structs with the same name??