Skip to content

Commit

Permalink
Better TS error report
Browse files Browse the repository at this point in the history
  • Loading branch information
PalumboN committed Mar 17, 2018
1 parent a64770a commit fdbbcf9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class MethodTypeInferenceTestCase extends AbstractWollokTypeSystemTestCase {
}
'''.parseAndInfer.asserting [
assertTypeOf(classTypeFor(NUMBER), "number")
findByText("number", WVariableReference).assertIssuesInElement("type <<Number>> does not understand message <<isBig>>")
findByText("number.isBig()", WMemberFeatureCall).assertIssuesInElement("type <<Number>> does not understand message <<isBig()>>")
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TypeSystemException extends RuntimeException {
* (Currently optional) type variable.
* This is highly coupled with ConstraintBasedTypeSystem, but given that we maybe deleting the others
* I thought it is not worth to do something more sophisticated to avoid the coupling.
* Anyway, other type systems should work correctly without a type variable asigned in their exceptions.
* Anyway, other type systems should work correctly without a type variable assigned in their exceptions.
*/
@Accessors
TypeVariable variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class OffenderSelector {
def static handleOffense(TypeVariable subtype, TypeVariable supertype, TypeSystemException offense) {
val offender = selectOffenderVariable(subtype, supertype)
offender.addError(offense)
offense.variable = offender
if (offense.variable === null) offense.variable = offender
}

def static selectOffenderVariable(TypeVariable subtype, TypeVariable supertype) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class MessageSend {
def addOpenType(WollokType type) {
openTypes.add(type)
}

def text() { //TODO: Consultar de dónde puedo sacar esto
'''«selector»(«arguments.map[it.owner].join(', ')»)'''
}

override toString() { returnType.owner.debugInfo }
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class TypeVariable implements ITypeVariable {
errors.forEach [
log.debug('''Reporting error in «owner.debugInfo»: «message»''')
try {
validator.report(message, owner)
validator.report(message, variable.owner)
}
catch (IllegalArgumentException exception) {
// We probably reported a type error to a core object, which is not possible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ class MessageNotUnderstoodException extends TypeSystemException {
new(WollokType type, MessageSend message) {
this.type = type
this.messageSend = message
this.variable = message.returnType
}

override getMessage() {
'''type <<«type»>> does not understand message <<«messageSend.selector»>>'''
'''type <<«type»>> does not understand message <<«messageSend.text»>>'''
}
}

0 comments on commit fdbbcf9

Please sign in to comment.