Inconsistent compile error

agraham

Expert
Licensed User
Longtime User
B4X:
-------------
Module "Main"
-------------

Sub Globals
   'Declare the global variables here.
End Sub

Sub App_Start
   Form1.Show
End Sub

Sub test
   Msgbox("Main")
End Sub

------------
Module "Test"
------------
Sub Globals
   'Declare the global variables here.
End Sub

Public Sub test
   Msgbox("Test")
End Sub
I know that this is probably caused by having a Sub the same name as a Module but the behaviour seems inconsistent to me.

If I have two Subs named "test" in the two modules I get a duplicate key compile error when I run it in the IDE.

If I only have one Sub named "test" in either of the modules I don't get the compile error.

If I change the names to both "test1" then I don't get a compile error.

So why can I have one Sub named the same as a module but not two? I would expect either none, or as many as I have modules.
 
Top