compiler: Validate constant slice bounds in safe code
f58cc10a39a1a3aaa3311d21a9e468b70367d83bca2773af047d296e25a38cde
1 parent
287a66c8
lib/std/lang/resolver.rad
+2 -2
| 7732 | 7732 | if let end = range.end { |
|
| 7733 | 7733 | try checkIndex(self, end); |
|
| 7734 | 7734 | } |
|
| 7735 | 7735 | } |
|
| 7736 | 7736 | ||
| 7737 | - | /// Emit an error when a slice range with compile-tyime values exceeds the array length. |
|
| 7738 | - | unsafe fn validateArraySliceBounds 'arena (self: &mut Resolver 'arena, range: ast::Range, length: u32, site: *ast::Node) throws (ResolveError) { |
|
| 7737 | + | /// Emit an error when constant slice bounds exceed the array length or are reversed. |
|
| 7738 | + | fn validateArraySliceBounds 'arena (self: &mut Resolver 'arena, range: ast::Range, length: u32, site: *ast::Node) throws (ResolveError) { |
|
| 7739 | 7739 | let mut startVal: ?u32 = nil; |
|
| 7740 | 7740 | let mut endVal: ?u32 = length; |
|
| 7741 | 7741 | ||
| 7742 | 7742 | if let startNode = range.start { |
|
| 7743 | 7743 | if let val = constSliceIndex(self, startNode) { |