cody icon indicating copy to clipboard operation
cody copied to clipboard

bug: Program listing generated is missing the end of program

Open nowhereman999 opened this issue 1 year ago • 2 comments

Version

1.12.0

Describe the bug

I asked Cody to write a program to parse an expression in QB64 BASIC but it doesn't supply the entire program. It stops before ending.

I asked: why are you not finishing the entire program? It responds: You're absolutely right, I should have provided the complete program without stopping midway. Here's the full code without any functions to evaluate the given expression:

Here's the code it produces.. DEFINT A-Z DIM expr$, c$, i%, value%, j%, temp%, k%, op% expr$ = "45-3((((15-3)2)+2)+51-6(22+1))*22"

PRINT "Expression: " + expr$

i = 0 value% = 0 op% = 0 ' 0 for addition/subtraction, 1 for multiplication/division

DO WHILE i <= LEN(expr$) c$ = MID$(expr$, i + 1, 1) IF c$ >= "0" AND c$ <= "9" THEN IF op% = 0 THEN value% = value% * 10 + VAL(c$) ELSE temp% = temp% * 10 + VAL(c$) END IF i = i + 1 ELSEIF c$ = "(" THEN i = i + 1 temp% = 0 DO j% = i DO WHILE j% <= LEN(expr$) c$ = MID$(expr$, j% + 1, 1) IF c$ >= "0" AND c$ <= "9" THEN temp% = temp% * 10 + VAL(c$) j% = j% + 1 ELSEIF c$ = "(" THEN j% = j% + 1 DO k% = j% DO WHILE k% <= LEN(expr$) c$ = MID$(expr$, k% + 1, 1) IF c$ >= "0" AND c$ <= "9" THEN temp% = temp% * 10 + VAL(c$) k% = k% + 1 ELSEIF c$ = ")" THEN EXIT DO END IF LOOP j% = k% LOOP UNTIL c$ = ")" ELSEIF c$ = "+" THEN j% = j% + 1 DO WHILE j% <= LEN(expr$) c$ = MID$(expr$, j% + 1, 1) IF c$ >= "0" AND c$ <= "9" THEN temp% = temp% + VAL(c$) j% = j% + 1 ELSE EXIT DO END IF LOOP ELSEIF c$ = "-" THEN j% = j% + 1 DO WHILE j% <= LEN(expr$) c$ = MID$(expr$, j% + 1, 1) IF c$ >= "0" AND c$ <= "9" THEN temp% = temp% - VAL(c$) j% = j% + 1 ELSE EXIT DO END IF LOOP ELSEIF c$ = "*" THEN op% = 1 j% = j% + 1 DO WHILE j% <= LEN(expr$) c$ = MID$(expr$, j% + 1, 1) IF c$ >= "0" AND c$ <= "9" THEN temp% = temp% * VAL(c$) j% = j% + 1 ELSE EXIT DO END IF LOOP ELSEIF c$ = "/" THEN op% = 1 j% = j% + 1 DO WHILE j% <= LEN(expr$) c$ = MID$(expr$, j% + 1, 1) IF c$ >= "0" AND c$ <= "

Expected behavior

It should produce the entire program, I asked it repeatedly but it just keep generating the same code then stops before it completes.

Additional context

No response

nowhereman999 avatar Apr 14 '24 18:04 nowhereman999

Related to https://github.com/sourcegraph/cody/issues/3648

umpox avatar Apr 15 '24 08:04 umpox

Thanks for reporting! We have increased Cody's output limit, it should now be much rarer to see Cody truncating the response like this. Let us know if you encounter any more issues!

This change will be available in this weeks Cody release, which is scheduled to go out either today or tomorrow.

umpox avatar Apr 17 '24 09:04 umpox

This issue is marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed automatically in 5 days.

github-actions[bot] avatar Jul 11 '24 01:07 github-actions[bot]