Menu

Inline comment trips up IF EXIT ( <comment> ) THEN

2024-08-19
2024-08-19
  • David C. Norris

    David C. Norris - 2024-08-19

    Here's a repro on PIC24

    : sayfalse ( f -- ) if exit then ." false" ;
    : weird ( f -- ) if exit ( ) then ." false" ;
    

    After defining WEIRD, I find a reset necessary because I lose the console interaction.
    After the reset, SAYFALSE functions as expected, but WEIRD does nothing:

    -1 sayfalse  ok<#,ram> 
    0 sayfalse false ok<#,ram> 
    -1 weird  ok<#,ram> 
    0 weird  ok<#,ram> 
    

    I came across this problem when injecting what I supposed would be an innocuous stack comment ( ) immediately after an EXIT (amid more complicated logic) to indicate that it would leave an empty stack. Interestingly, in that case the act of defining the word pushed a pointer onto the stack; this was how I noticed the problem. If this issue is worth chasing, I'm glad to try assembling a repro that exhibits that pointer-pushing behavior.

     
  • Mikael Nordman

    Mikael Nordman - 2024-08-19

    It works if you actually insert a comment.
    If you have only one space between the brackets then it falls apart.

    It's a bug but maybe not a disaster :-)

     
    😄
    1

Log in to post a comment.