Wiki

Ticket #116 (closed defect: fixed)

Opened 16 years ago

Last modified 12 years ago

multiline expression in if statement has undesirable restriction on indentation

Reported by: hopscc Owned by: Chuck
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

If write a multiline expression in an if statement unless the expression is indented like so

    if a == 99 and
    b == 99
        print 'compiled OK'

( i.e dangling expression on following line at same indentation)
you get a parse error
as in

		if  (a > 98 and
			b == 99 )   # trailing line 1 indent in
			print 'OK - 1'
		else
			print 'fail'
# OR		
		if  (a > 98 and
				b == 99 ) #  2 indents in
			print 'OK - 2'
		else
			print 'fail'

Parse error is something like

 Expecting INDENT, but got "print" instead.

Error genereted is actually on first line of following block.

Attachments

multiline-if-indent.patch Download (3.6 KB) - added by hopscc 16 years ago.

Change History

Changed 16 years ago by hopscc

Changed 16 years ago by hopscc

patchfile incl test
see also ticket:112

Changed 16 years ago by hopscc

  • owner set to Chuck
  • status changed from new to assigned

Changed 16 years ago by Chuck

When you say "see also ticket:112" do you mean that this patch is related to that? Or just that ticket:112 is related to this ticket?

Changed 16 years ago by hopscc

Just that the tickets are related (and so any patches will interrelate/interact)
if this fix applied theres no restriction on indentation of continued lines
If do actually want to limit/fix allowable indentation of continued lines then should apply this fix first then add code to enforce limitations.

Changed 15 years ago by hopscc

  • summary changed from multiline expression in if statement has undersirable restriction on indentation to multiline expression in if statement has undesirable restriction on indentation

Changed 12 years ago by Charles

  • status changed from assigned to closed
  • resolution set to fixed

Applied in changeset:2783 which also fixes ticket:112

Changed 12 years ago by Charles

I meant ticket:211 in the last comment.

Note: See TracTickets for help on using tickets.