Issue Details (XML | Word | Printable)

Key: BOO-1113
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Cedric Vivier
Reporter: Cedric Vivier
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Ensure all exception handlers can be reached

Created: 16/Jan/09 06:52 AM   Updated: 16/Jan/09 06:59 AM   Resolved: 16/Jan/09 06:59 AM
Return to search
Component/s: Compiler
Affects Version/s: 0.8.2
Fix Version/s: 0.9

Time Tracking:
Not Specified

Testcase included: yes


 Description  « Hide

Boo should issue an error when an except block is unreachable because a previous block handles a super type of the exception (or the same exception).

Testcase:

"""
BCE0165-1.boo(17,11): BCE0165: 'System.ArgumentException' is already handled by except block for 'System.Exception' at (15,11).
BCE0165-1.boo(19,11): BCE0165: 'System.ArgumentNullException' is already handled by except block for 'System.ArgumentException' at (17,11).
BCE0165-1.boo(21,11): BCE0165: 'System.NotImplementedException' is already handled by except block for 'System.Exception' at (15,11).
BCE0165-1.boo(23,11): BCE0165: 'System.ArgumentException' is already handled by except block for 'System.ArgumentException' at (17,11).
"""
import System

x = 1

try:
	print "foo"
except as InvalidOperationException:
	pass
except as Exception:
	pass
except as ArgumentException:
	pass
except as ArgumentNullException:
	pass
except as NotImplementedException:
	pass
except as ArgumentException: #dupe
	pass

try:
	print "bar"
except as ArgumentException if x == 1:
	pass
except as ArgumentException: #not a dupe (filter)
	pass


Cedric Vivier made changes - 16/Jan/09 06:54 AM
Field Original Value New Value
Description Boo should issue an error when an except block is unreachable because a previous block handles a super type of the exception (or the same exception).

Testcase:
{code}
"""
BCE0165-1.boo(17,11): BCE0165: 'System.ArgumentException' exception is already handled by except block for 'System.Exception' at (15,11).
BCE0165-1.boo(19,11): BCE0165: 'System.ArgumentNullException' exception is already handled by except block for 'System.ArgumentException' at (17,11).
BCE0165-1.boo(21,11): BCE0165: 'System.NotImplementedException' exception is already handled by except block for 'System.Exception' at (15,11).
BCE0165-1.boo(23,11): BCE0165: 'System.ArgumentException' exception is already handled by except block for 'System.ArgumentException' at (17,11).
"""
import System

x = 1

try:
print "foo"
except as InvalidOperationException:
pass
except as Exception:
pass
except as ArgumentException:
pass
except as ArgumentNullException:
pass
except as NotImplementedException:
pass
except as ArgumentException: #dupe
pass

try:
print "bar"
except as ArgumentException if x == 1:
pass
except as ArgumentException: #not a dupe (filter)
pass
{code}
Boo should issue an error when an except block is unreachable because a previous block handles a super type of the exception (or the same exception).

Testcase:
{code}
"""
BCE0165-1.boo(17,11): BCE0165: 'System.ArgumentException' is already handled by except block for 'System.Exception' at (15,11).
BCE0165-1.boo(19,11): BCE0165: 'System.ArgumentNullException' is already handled by except block for 'System.ArgumentException' at (17,11).
BCE0165-1.boo(21,11): BCE0165: 'System.NotImplementedException' is already handled by except block for 'System.Exception' at (15,11).
BCE0165-1.boo(23,11): BCE0165: 'System.ArgumentException' is already handled by except block for 'System.ArgumentException' at (17,11).
"""
import System

x = 1

try:
print "foo"
except as InvalidOperationException:
pass
except as Exception:
pass
except as ArgumentException:
pass
except as ArgumentNullException:
pass
except as NotImplementedException:
pass
except as ArgumentException: #dupe
pass

try:
print "bar"
except as ArgumentException if x == 1:
pass
except as ArgumentException: #not a dupe (filter)
pass
{code}
Cedric Vivier added a comment - 16/Jan/09 06:59 AM

Fixed in rev 3110


Cedric Vivier made changes - 16/Jan/09 06:59 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]