Commits

Carl Friedrich Bolz committed 09e3706

fix off-by-one erorrs

Comments (0)

Files changed (2)

prolog/interpreter/error.py

         rule = self.rule
         if rule.line_range is not None:
             if rule.line_range[0] + 1 ==  rule.line_range[1]:
-                lines = "line %s " % (rule.line_range[0], )
+                lines = "line %s " % (rule.line_range[0] + 1, )
             else:
                 lines = "lines %s-%s " % (rule.line_range[0] + 1, rule.line_range[1])
         else:

prolog/interpreter/test/test_error.py

     f(X, Y) :-
         g(X),
         h(Y).
-  File "<unknown>" line 3 in user:g/1
+  File "<unknown>" line 4 in user:g/1
     g(_) :- throw(foo).
 Unhandled exception: foo"""
 
     assert s == """\
 Traceback (most recent call last):
   File "<unknown>" in user:h/0
-  File "<unknown>" line 3 in user:g/1
+  File "<unknown>" line 4 in user:g/1
     g(_) :- throw(foo).
 Unhandled exception: foo"""
 
     f(X, Y) :-
         g(X),
         h(Y).
-  File "<unknown>" line 3 in user:g/1
+  File "<unknown>" line 4 in user:g/1
     g(_) :- _ is _.
 is/2: arguments not sufficiently instantiated"""