Danger! Type-checking & the translator
- Posted by Andy Serpa <ac at onehorseshy.com> Jan 27, 2003
- 404 views
Hello, I know that translated programs don't do type-checking, but I assumed this was for built-in Euphoria types, not user-specifed types. Apparently I was wrong. Take the following program: integer z z = 0 type test(object x) z = 1 return 1 end type test y y = 4 ? z Now every time y is assigned a value, it has the side effect of assining a value to z. Run with the interpreter, and the output is: 1 Translated, the output is 0 -- the type code is never called. Unless I'm just doing something stupid, this is major. Anything that depends on custom-types for exception handling or these type of side effects won't work when translated. This breaks *LOTS* of code when translating, including major libraries like Mike Nelson's Diamond. Why isn't this in the docs? The translator docs say: "Note: The translator assumes that your program has no run-time errors in it that would be caught by the interpreter. The translator does not check for: subscript out of bounds, variable not initialized, assigning the wrong type of data to a variable, etc. " This goes way beyond debugging. It should say, "You can't use custom types in translated programs, period." Please tell me I'm wrong about this...