hpi-swa-teaching/PrettyPrettyPrint

PrettyPrinting parenthesis removal changes semantics

Opened this issue · 0 comments

Description
When PrettyPrinting with the option 'remove unnecessary parentheses', the semantics of the generated code are changed.

Example
Pre-PPP:

handleStatusChange
	| newStatus |
	newStatus := self repository buildStatus.
	(self status ~= newStatus
			and: [newStatus = #failed
					or: [newStatus = #errored]
					or: [newStatus = #canceled]
					or: [newStatus = #passed]])
		ifTrue: [ATDDSoundPlayer instance playSoundForStatus: newStatus].

Post-PPP:

handleStatusChange
	
	| newStatus |
	
	newStatus := self repository buildStatus.
	self status
		~= newStatus
		and: [
			newStatus
				= #failed
				or: [ newStatus = #errored ]
				or: [ newStatus = #canceled ]
				or: [ newStatus = #passed ] ]
		ifTrue: [ ATDDSoundPlayer instance playSoundForStatus: newStatus ]

Expected behavior
The semantics of the code are not changed.

Environment (please complete the following information):

  • Used Version: 9af2814
  • OS: [Win10/ SWTv1]

Additional context
The error thrown is 'self status' does not understand 'and: ifTrue:' (because the parentheses were removed.