Menu

#432 Problem with Procedure Parameters  Edit

compiler
open
None
2025-01-19
2025-01-17
No

The following problem was reported by our Praktikum and has to be checked.

With two parameters the attached procedure fails to compile. Maybe this is problem with INV parameters.

PumpModeChanged: PROC(aNewState INV FIXED(2), aNewPumpRate INV FIXED(31));
  DCL state_changed BIT(1);
  IF pumpMode /= aNewState THEN
    state_changed := ('1'B1);
  ELSE
    state_changed := ('0'B1);
  FIN;
  pumpMode := aNewState;
  IF state_changed THEN
    CASE pumpMode
      ALT (pumpState_OFF)
        LogInformation('Pump is turning off');
      ALT (pumpState_IDLE)
        LogInformation('Pump set to idle speed');
      ALT (pumpState_ACTIVE)
        LogInformation('Pump is active');
      OUT
        LogWarning('Error: Invalid pump mode');
    FIN;
  FIN;
END;

Discussion

  • Rainer Müller

    Rainer Müller - 2025-01-18

    This seams to be solved in the meantime.

    The following code compiles without errors, The IMC complains about the undefinded procedures.

    MODULE(t432);
    PROBLEM;
    DCL pumpMode FIXED;
    DCL (pumpState_OFF , pumpState_IDLE, pumpState_ACTIVE) INV FIXED INIT(1,2,3);
    
    SPC LogInformation PROC( t REF INV CHAR()) GLOBAL(other);
    SPC LogWarning PROC( t REF INV CHAR()) GLOBAL(other);
    
    PumpModeChanged: PROC(aNewState INV FIXED(2), aNewPumpRate INV FIXED(31));
      DCL state_changed BIT(1);
      IF pumpMode /= aNewState THEN
        state_changed := ('1'B1);
      ELSE
        state_changed := ('0'B1);
      FIN;
      pumpMode := aNewState;
      IF state_changed THEN
        CASE pumpMode
          ALT (pumpState_OFF)
            LogInformation('Pump is turning off');
          ALT (pumpState_IDLE)
            LogInformation('Pump set to idle speed');
          ALT (pumpState_ACTIVE)
            LogInformation('Pump is active');
          OUT
            LogWarning('Error: Invalid pump mode');
        FIN;
      FIN;
    END;
    MODEND;
    
     
  • Rainer Müller

    Rainer Müller - 2025-01-19

    If the definition of pumpMode is missing the compiler complains:

    ticket432.prl:11:6: error: 'pumpMode' is not defined
      IF pumpMode /= aNewState THEN
         ^
    ticket432.prl:11:6: internal compiler error: NE: no AST attribute found for lhs of operation NE
        please send a bug report
      IF pumpMode /= aNewState THEN
         ^
    ticket432.prl:16:3: error: assignment: 'pumpMode' is not defined
      pumpMode := aNewState;
      ^
    ticket432.prl:18:10: error: 'pumpMode' is not defined
        CASE pumpMode
             ^
    compilation aborted with errors
    

    The message 'internal compiler error' should be removed, since this is already complained with the first error message.
    The supression of further error messages concerning the same undefined elements may be object for V2 of the compiler

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB