Project

General

Profile

Bug #344

basic_string::erase error in interpreter

Added by John Abbott almost 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Parser/Interpreter
Target version:
Start date:
24 Apr 2013
Due date:
% Done:

100%

Estimated time:
Spent time:

Description

Save the following in a file, and then use send-region (without final newline) to send it to CoCoA:

OrderMatrix := Mat([[1,0,0],
            [0,1,0],
            [,0,1]]);

This produces a basic_string::erase error!!


Related issues

Related to CoCoA-5 - Feature #8: source regionClosed2011-10-20

History

#1 Updated by John Abbott almost 11 years ago

Found by Giulia Marconi.

#2 Updated by John Abbott almost 11 years ago

  • Assignee set to John Abbott

The same error occurs even when the input is syntactically correct (but without final newline):

OrderMatrix := Mat([[1,0],
            [0,1]]);

Adding a final space did not eliminate the error.

The error does not arise if the input resides on a single line [without TAB char]

The error does not arise if the second line does not contain a TAB char.

The error does arise with a single line containing a TAB char!

#3 Updated by John Abbott almost 11 years ago

I'm 99% certain I know what the problem is: when emacs generates the SopurceRegion command it uses column position as a character count,
but this is not valid if there are TAB characters in the line!!

I note that CoCoAInterpreter does not make a mistake when indicating
the position of an error in a line because it prints out a TAB as just
a single space. Presumably the Emacs code must compute the difference
between the values of (point) at the start of the line and at the region
end in the line.

#4 Updated by John Abbott almost 11 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 80

I believe I have found and resolved the problem. Make the following change:

(defun cocoa5-column-number-at-pos (pos)
  (save-excursion
    (progn
      (goto-char pos)
      (setq end-pt (point))
      (forward-line 0) ;; move to beginning of line
      (setq start-pt (point))
      (- end-pt start-pt))))

Hmm, maybe I should change the fn name.
Done new name is cocoa5-char-index-in-line

The trouble was indeed that column count is not the same as character count.

I should probably also add a better error check in the SourceRegion command.
Done error message is a bit cryptic (but I doubt it matters because no one should ever type in the command by hand).

#5 Updated by John Abbott almost 11 years ago

An error is reported if the region selected starts after the last character on a line (e.g. starting at an empty line). The problem is that Emacs indicates a column position "one after the last char" (presumably the position of the newline).

Update: fixed, change line 110 in LineProviders.C (will check in tmrw)

#6 Updated by John Abbott almost 11 years ago

  • Status changed from Resolved to Feedback
  • % Done changed from 80 to 90

No further problems have come to light in the last 2 weeks, so I'm changing the state to feedback (hoping to close the issue before the COCOA school).

#7 Updated by John Abbott almost 11 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

No futher problems found in 3 weeks, so closing this issue.

Also available in: Atom PDF