Skip to content

Instantly share code, notes, and snippets.

@Skrylar
Created March 16, 2014 10:18
Show Gist options
  • Save Skrylar/9581181 to your computer and use it in GitHub Desktop.
Save Skrylar/9581181 to your computer and use it in GitHub Desktop.
Code to demonstrate a crash in the Nimrod compiler. Its important that both files are separate, combining the two makes the crash go away.
import
rectangle
type
MaxRectPacker* [T] = object
initialWidth, initialHeight: T
freeGeometry: seq[Rectangle[T]]
proc TryGet* [T](self: var MaxRectPacker[T];
width, height: T;
outRectangle: var Rectangle[T]): bool =
var rect : Rectangle[T]
return false
when isMainModule:
proc FourCorners() =
var packer : MaxRectPacker[int]
var outRect : Rectangle[int]
packer.TryGet(32, 32, outRect)
FourCorners()
type
Rectangle*[T] = object
Left*, Top*, Right*, Bottom*: T
proc Set*[T](self: var Rectangle[T]; lf, tp, bm, rg: T) =
## Modifies the rectangle in-place, setting each element of the
## rectangle in a single procedure call.
self.Left = lf
self.Top = tp
self.Bottom = bm
self.Right = rg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment