MEGA65 / mega65-rom-public

MEGA65 ROM public issue reporting
4 stars 0 forks source link

RENUMBER removing whitespace after THEN #18

Closed rscottfree closed 1 year ago

rscottfree commented 2 years ago

Test Environment (required)

Describe the bug Renumbering a basic program with THEN keyword will remove any whitespace that comes after THEN.

To Reproduce

  1. Create a basic program like this:

    10 IF I=0 THEN PRINT "HI"

  2. Then run RENUMBER10,10

  3. List the program and you'll see the removed whitespace between THEN AND PRINT.

    10 IF I=0 THENPRINT "HI"

Expected behavior It would be nice if the whitespace were preserved as it appears to be for other keywords

Additional context It behaves the same whether it's a logical or numeric expression after the THEN keyword. I consider this low priority but wanted to document it.

dansanderson commented 1 year ago

This is ~an undocumented~ a "feature" of RENUMBER. If you omit the space between RENUMBER and its first argument, it will omit the whitespace that precedes line numbers in the translated source.

Try RENUMBER 10,10 in the example above and it'll preserve the whitespace. Note that if the source started out with no space before the line number, it'll stay that way in either case.

I don't know what to say about this dubious feature, but it's clearly intentional from the code, so not really a bug. ~If anyone wants me to remove it such that whitespace is preserved regardless of invocation, please reopen the ticket and I'll gladly do so.~ 😄

dansanderson commented 1 year ago

Someone pointed out that this is actually a documented feature, I just didn't notice because it's newer than the printed User's Guide. I'm not happy with the documented justification of the feature or its design, but that's separate from the issue being reported here. The requested improvement is for this "optimisation" mode to not remove spaces after THEN if THEN is not followed by a line number.

I'll file a separate issue to propose changing its calling syntax to be more consistent with the rest of the API, e.g. RENUMBER C ... to "crunch" spaces.