Boo

Compilation error with generator function with exception handling

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 0.8.2
  • Fix Version/s: 0.9
  • Component/s: None
  • Labels:
    None
  • Patch Submitted:
    Yes
  • Number of attachments :
    1

Description

import System.Collections.Generic

def foo() as IEnumerator[of int]:
try:
print "test"
except e:
print "An exception occurred"
return

for i in range(5):
yield i

foo()

Boo Compiler version 0.8.2.2960 (CLR v2.0.50727.1433)
bug1.boo(6,3): BCE0055: Internal compiler error: Value cannot be null.
Parameter name: local.
1 error(s).

Activity

Hide
Cedric Vivier added a comment -

As posted on the list :

The attached patch fixes the problem.
For some reason, when the method is a generator (contains yield
statements), the 'local' used as the exception handler is not visited
and thus does not have a LocalBuilder handy.

I'm not commiting it yet since it is more a workaround hack than a
solution to the actual problem (the node not being visited), but well
have not much time to do it now and debugging a visitor pattern by
omission (code not run) is quite time-consuming :s

Show
Cedric Vivier added a comment - As posted on the list : The attached patch fixes the problem. For some reason, when the method is a generator (contains yield statements), the 'local' used as the exception handler is not visited and thus does not have a LocalBuilder handy. I'm not commiting it yet since it is more a workaround hack than a solution to the actual problem (the node not being visited), but well have not much time to do it now and debugging a visitor pattern by omission (code not run) is quite time-consuming :s
Hide
Cedric Vivier added a comment -

Marking it blocker just so not to forget to check in above patch if the issue is still not properly fixed in time for 0.9 release.

Show
Cedric Vivier added a comment - Marking it blocker just so not to forget to check in above patch if the issue is still not properly fixed in time for 0.9 release.
Hide
Rodrigo B. de Oliveira added a comment -

GeneratorMethodProcessor transforms every local variable into a field of the IEnumerator implementation. This is clearly wrong for exception variables because their scope never outlives a single method invocation.

Show
Rodrigo B. de Oliveira added a comment - GeneratorMethodProcessor transforms every local variable into a field of the IEnumerator implementation. This is clearly wrong for exception variables because their scope never outlives a single method invocation.
Hide
Rodrigo B. de Oliveira added a comment -

Fixed in rev. 3101.

Show
Rodrigo B. de Oliveira added a comment - Fixed in rev. 3101.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: