Euphoria Ticket #563: Resolve default parameters in the scope of their declaration

Default parameters may be resolved as though they were explicitly entered at the point of the call rather than where their routine is declared. This can lead to confusing results and errors, and added dependencies, especially when the default parameter uses a symbol from a file different than where the routine is declared.

Details

Type: Bug Report Severity: Normal Category: Front End
Assigned To: mattlewis Status: Fixed Reported Release:
Fixed in SVN #: View VCS: none Milestone: 4.0.5

1. Comment by petelomax Apr 28, 2011

See also ticket 658 (marked as duplicate)

2. Comment by mattlewis Apr 24, 2012

Link to duplicate: ticket:658

3. Comment by mattlewis Apr 24, 2012

A single file example based on the code presented in ticket:658:

namespace t 
 
constant x = "12345" 
procedure p(integer i=length(x)) 
  printf(1,"the length of %s is %d\n",{x,i}) 
end procedure 
 
procedure main() 
	sequence x = "123" 
	p()                -- the length of 12345 is 3 <-- WRONG! 
	p( length( t:x ) ) -- the length of 12345 is 5 
end procedure 
main() 

4. Comment by mattlewis Apr 25, 2012

Moving to 4.0.5. Also, we should do forward reference resolution:

-- bug.e 
public function foo( integer x = a ) 
    return x + 1 
end function 
 
-- bug.ex 
include bug.e 
? foo() 

5. Comment by mattlewis Apr 25, 2012

See: hg:euphoria/rev/37e21790b20c

changeset: 5546:37e21790b20c branch: 4.0 tag: tip parent: 5542:f4c256900ff0 user: Matt Lewis date: Wed Apr 25 07:46:42 2012 -0400 files: source/parser.e tests/t_defparms.e description:

  • if a default parameter value is resolved, use that symbol, do not attempt to resolve again when the routine is called
  • added test to t_defparms.e
  • ticket 563

6. Comment by mattlewis Apr 26, 2012

See: hg:euphoria/rev/0733e000f389

changeset: 5547:0733e000f389 branch: 4.0 user: Matt Lewis date: Thu Apr 26 15:19:06 2012 -0400 files: source/fwdref.e source/parser.e tests/defparam1.e tests/defparam2.e tests/t_defparms.e description:

  • delayed resolution of default parameter values, including updated unit tests
  • fixes ticket 563

7. Comment by mattlewis Apr 26, 2012

See: hg:euphoria/rev/d2d529ba243f

changeset: 5548:d2d529ba243f branch: 4.0 user: Matt Lewis date: Thu Apr 26 15:25:19 2012 -0400 files: docs/release/4.0.5.txt description:

  • release notes for ticket 563

8. Comment by mattlewis Apr 26, 2012

See: hg:euphoria/rev/243ea1f60402

changeset: 5549:243ea1f60402 parent: 5545:6b3fc2c6be44 parent: 5548:d2d529ba243f user: Matt Lewis date: Thu Apr 26 16:14:26 2012 -0400 files: source/fwdref.e source/parser.e tests/t_defparms.e description:

  • merge ticket 563 changes into the trunk from 4.0

Search



Quick Links

User menu

Not signed in.

Misc Menu