Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 23 additions & 0 deletions src/AST-Core/RBNotice.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ Class {
#category : #'AST-Core-Notice'
}

{ #category : #comparing }
RBNotice >> <= other [

self errorLevel = other errorLevel ifFalse: [
^ self errorLevel > other errorLevel ]. "Errors before warnings"
^ self position <= other position
]

{ #category : #accessing }
RBNotice >> description [

Expand All @@ -31,6 +39,15 @@ RBNotice >> description [
nextPutAll: (node sourceCode asString withBlanksCondensed truncateWithElipsisTo: 60) ]
]

{ #category : #'error handling' }
RBNotice >> errorLevel [

self isSyntaxError ifTrue: [ ^ 3 ].
self isError ifTrue: [ ^ 2 ].
self isWarning ifTrue: [ ^ 1 ].
^ 0
]

{ #category : #inspecting }
RBNotice >> inspectionSource [

Expand All @@ -44,6 +61,12 @@ RBNotice >> isError [
^ false
]

{ #category : #testing }
RBNotice >> isSyntaxError [

^ false
]

{ #category : #testing }
RBNotice >> isUndeclaredNotice [

Expand Down
6 changes: 6 additions & 0 deletions src/AST-Core/RBSyntaxErrorNotice.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Class {
#category : #'AST-Core-Notice'
}

{ #category : #testing }
RBSyntaxErrorNotice >> isSyntaxError [

^ true
]

{ #category : #accessing }
RBSyntaxErrorNotice >> messageText [

Expand Down
2 changes: 1 addition & 1 deletion src/OpalCompiler-Core/OpalCompiler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ OpalCompiler >> parse [
self doSemanticAnalysis.

self permitFaulty ifFalse: [
ast allNotices do: [ :n |
ast allNotices sorted do: [ :n |
| check |
check := self checkNotice: n.
check ifNil: [ ^ ast ].
Expand Down
15 changes: 15 additions & 0 deletions src/OpalCompiler-Tests/OCCompilerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ OCCompilerTest >> testAssignmentOfGlobalVarBinding [
compile
]

{ #category : #tests }
OCCompilerTest >> testErrorOrders [

| ast notices |
ast := OpalCompiler new parse: 'foo | b | ^ a + ¿. 5 "what'.
notices := ast allNotices sorted
collect: [ :e |
e position asString , ':' , e messageText ]
as: Array.
self
assertCollection: notices
equals: #( '17:Unknown character' '27:Unmatched " in comment.'
'13:Undeclared variable' '7:Unused variable' '20:Unreachable statement' )
]

{ #category : #'tests - shadowing' }
OCCompilerTest >> testInBlockArgumentInstanceVariableShadowing [
self initializeErrorMessage.
Expand Down