Comments (6)
The Oberon 2 spec defines ASH in section 10.3 Predeclared procedures. It's result type is fixed as LONGINT.
Since int2 is an INTEGER, it's not large enough to hold the result.
(Maybe it would be reasonable to be less fussy, but I believe that's the fundamental reason for this error.)
Does the Oxford Oberon2 spec have anything to say about the result type of ASH or the parameter types of INC that allow this?
from voc.
this compiles:
MODULE test;
VAR
int,int2 : INTEGER;
BEGIN
int := 1234;
int2 := 0;
INC(int2, SHORT(ASH(int,24)));
END test.
report states, that the output type of ASH is LONGINT, and the argument types of INC(v, n) should be integer types. LONGINT is also an integer type. For some reason OP2 expects INTEGER as an argument type of INC?
from voc.
Ah, @dcwbrown is right.
MODULE test;
VAR
int,int2 : LONGINT;
BEGIN
int := 1234;
int2 := 0;
INC(int2, ASH(int,24));
END test.
This also compiles. The reason is int2's type.
from voc.
Yes, it makes sense.
In INC(v,n) v and n are defined as integer type (that means SHORTINT, INTEGER or LONGINT), but of course expression n must have the same type of v, although the report says nothing about this and of course this is the reason why other Oberon compilers don't complain.
(Maybe it would be reasonable to be less fussy, but I believe that's the fundamental reason for this error.)
In my opinion this behaviour is correct, the semantic is the same as v := v+n; and since there is a LONGINT type in the expression, the result must be LONGINT.
By the way, I would improve error messages for Oberon specific procedures and function procedures.
from voc.
expression n must have the same type of v
Uhm, that's not entirely correct, since it will exclude type inclusion. Anyway, assignment rule applies in this case.
from voc.
can anyone suggest more understandable error message for that case?
from voc.
Related Issues (20)
- FOR i := 0 TO Args.argc - 1 DO -> incompatible assignment HOT 15
- Slow reading big text files HOT 11
- parameter doesn't match (SYSTEM.ADDRESS) HOT 2
- SET is 64-bit in Component Pascal size model HOT 3
- x11 examples HOT 1
- runtime should kill when assigning to an unallocated pointer (was: returning pointer to a local variable) HOT 21
- uninitialized variable usage warning
- stabs debug format is not supported at least on one aarch64 platform. HOT 2
- Create Directory HOT 7
- pointer to record broken
- warning: implicit declaration of function
- Wrong Position when error occured HOT 2
- update gcc string to consider MODULES environment variable
- MOD issue HOT 21
- Improved C language interface HOT 11
- passing VAR s: POINTER TO ARRAY OF CHAR passes compilation but later doesn't compile in C HOT 2
- libvoc-02.so not found after make full HOT 1
- Files.WriteSet wrong type in SYSTEM.VAL HOT 3
- Make does not properly uninstall: typo in variable name HOT 1
- Error in WITH statement with pointers to related type extended records HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voc.