While the code above indeed has a lot of problems - and you will need to fix it to make do something meaningful, note that "Internal Error" means error not on your side, but a problem on compiler side. However, I've tried to reproduce it in the latest FPC trunk version and I don't get any Internal Error - the code compiles for me with fair warnings.
One of the simplest things to try "Run > Clean up and Build". If that doesn't work, try upgrading FPC version (e.g. through FPCUpDeluxe), maybe the issue has already been resolved.