Giter Club home page Giter Club logo

Comments (6)

dcwbrown avatar dcwbrown commented on August 10, 2024

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.

norayr avatar norayr commented on August 10, 2024

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.

norayr avatar norayr commented on August 10, 2024

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.

diegosardina avatar diegosardina commented on August 10, 2024

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.

diegosardina avatar diegosardina commented on August 10, 2024

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.

norayr avatar norayr commented on August 10, 2024

can anyone suggest more understandable error message for that case?

from voc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.