Euphoria Ticket #949: Forward referencing identifiers within a subroutine

Forward referencing identifiers at top-level scope is disallowed, and produces an error as expected:

? c 
? e 
 
constant c = 0 
enum e  

But forward referencing identifiers within a subroutine is allowed:

procedure foo() 
  ? c 
  ? e 
  ? i 
end procedure 
 
constant c = 0 
enum e  
integer i = 2 
 
foo() 

I believe this should be an error based on the documentation for variable/constant/enum that does not have a scope modifier "starts at the declaration and ends at the end of the file it is declared in"

Details

Type: Bug Report Severity: Minor Category: Front End
Assigned To: unknown Status: New Reported Release: 4.1.0 beta2
Fixed in SVN #: View VCS: none Milestone:

1. Comment by PeteE Dec 14, 2015

Hmm, I found an example in this in /forum/123526.wc, so it seems this is expected behavior. The documentation should be updated instead.

2. Comment by PeteE Dec 15, 2015

After considering this for a bit, it still seems inconsistent.

These forward references inside a subroutine are allowed:

set_i() 
foo() 
 
procedure foo() 
  ? c 
  ? e 
  ? i 
end procedure 
 
procedure set_i() 
  i = 2 
end procedure 
 
constant c = 0 
enum e 
integer i 

Yet, these at top-level are not: (despite having the same control-flow)

set_i() 
 
? c 
? e 
? i 
 
procedure set_i() 
  i = 2 
end procedure 
 
constant c = 0 
enum e 
integer i 

Top-level forward references from an include are allowed:

-- foo.e 
public constant c = 0 
public enum     e 
public integer  i 
-- foo.ex 
i = 2 
 
? c 
? e 
? i 
 
include foo.e 

So why aren't top-level forward references from the same file also allowed?

Search



Quick Links

User menu

Not signed in.

Misc Menu