Spivoxity / obc-3

Oxford Oberon-2 compiler
38 stars 7 forks source link

Internal compiler error: Can't pass value type type SHORTINT #33

Closed ghost closed 4 years ago

ghost commented 4 years ago

Received the infamous...

*** Oxford Oberon-2 compiler version 3.1.2alpha
*** Internal compiler error: Can't pass value type type SHORTINT
*** (This message should never be displayed: it may
***   indicate a bug in the Oberon compiler.
***   Please save your program as evidence and report
***   the error at 'https://bitbucket.org/Spivey/obc-3/issues'
***   or by e-mail to 'mike@cs.ox.ac.uk'.)

...while compiling...

PROCEDURE Socket*(domain, type, protocol: INTEGER):SHORTINT IS "socket";

...which admittedly is incorrect from what I can tell but I thought I'd bring it to your attention in case it was an edge case bug or you preferred a different error message. (I'm doing a straight port of some VOC compiler socket code to get everything working and it seems the return value is SHORTINT based on that compiler's default settings and the code provided.)

Oxford Oberon-2 compiler driver version 3.1.2alpha [build unknown]
Oxford Oberon-2 compiler version 3.1.2alpha [build unknown]
Oxford Oberon-2 linker version 3.1.2alpha [build unknown]
Oxford Oberon-2 runtime system version 3.1.2alpha [build unknown] (JIT)
Oxford Oberon-2 library version 3.1.2alpha [build unknown]
ghost commented 4 years ago

(Just FYI I've been able to get a basic echo server working well enough to encourage me to tighten everything up a bit. Thanks for all the help so far!)

Spivoxity commented 4 years ago

In this case (the value returned by a function), INTEGER and SHORTINT mean very much the same thing. I'll add SHORTINT as a possibility just for tidiness, with an implicit truncation of the actual result.

These are not really "internal compiler errors" but implementation restrictions that are detected during code generation. The proper solution would be to add checks to the semantic analysis phase and produce a proper error message -- but that would require duplicating the list of ad-hoc cases, and this language extension is anyway "for experts only".

You've no doubt worked out that INTEGER is 4 bytes in OBC, SHORTINT is 2 bytes, and LONGINT is 8 bytes. So, unlike the ETH compilers, it's rarely necessary to use LONGINT for anything.