Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/AST-Core-Tests/OCParserTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,17 @@ OCParserTest >> testReplacingNodes [
self assert: tree removeDeadCode equals: (self parserClass parseMethod: '+ q | q b | self ifTrue: [] ifFalse: [b := c]. q := b. {q. b}. ^q')
]

{ #category : 'tests' }
OCParserTest >> testReturnShouldBeTheLastStatement [

self
should: [ self parserClass parseMethod:
'tmp ^ 42. 33 + 33' ]
raise: Error.


]

{ #category : 'tests' }
OCParserTest >> testScopesEnclosingMatchingLiterals [
| tree |
Expand Down
2 changes: 1 addition & 1 deletion src/AST-Core/OCParser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ OCParser >> parseStatementInto: statementList periodList: periods withAcceptedSt
"If the previous node in the statement list is a return node, mark this node as unreachable"

(statementList notEmpty and: [ statementList last isReturn ]) ifTrue: [
node addWarning: 'Unreachable statement' ].
self error: 'After the return statement, there is an unreachable statement in this method source: ', source ].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is nice but will it forbid to have a comment after the return


"Commit the statement to the statements list"
statementList add: node
Expand Down