Browse Source

Do not ParseError-wrap smalltalk errors.

AST nodes may throw Smalltalk errors while
parser manipulates them. As is the case in pragmas in blocks.
Herby Vojčík 6 years ago
parent
commit
47f788899b
2 changed files with 16 additions and 11 deletions
  1. 15 11
      src/Kernel-Infrastructure.js
  2. 1 0
      src/Kernel-Infrastructure.st

+ 15 - 11
src/Kernel-Infrastructure.js

@@ -3584,40 +3584,44 @@ var pos;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$6,$5,$4,$3;
-$1=$recv(anException)._basicAt_("location");
+var $1,$2,$3,$7,$6,$5,$4;
+$1=$recv(anException)._isSmalltalkError();
+if($core.assert($1)){
+return $recv(anException)._resignal();
+}
+$2=$recv(anException)._basicAt_("location");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["basicAt:"]=1;
 //>>excludeEnd("ctx");
-pos=$recv($1)._start();
-$2=$recv($globals.ParseError)._new();
-$6=$recv("Parse error on line ".__comma($recv(pos)._line())).__comma(" column ");
+pos=$recv($2)._start();
+$3=$recv($globals.ParseError)._new();
+$7=$recv("Parse error on line ".__comma($recv(pos)._line())).__comma(" column ");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx[","]=4;
 //>>excludeEnd("ctx");
-$5=$recv($6).__comma($recv(pos)._column());
+$6=$recv($7).__comma($recv(pos)._column());
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx[","]=3;
 //>>excludeEnd("ctx");
-$4=$recv($5).__comma(" : Unexpected character ");
+$5=$recv($6).__comma(" : Unexpected character ");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx[","]=2;
 //>>excludeEnd("ctx");
-$3=$recv($4).__comma($recv(anException)._basicAt_("found"));
+$4=$recv($5).__comma($recv(anException)._basicAt_("found"));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx[","]=1;
 //>>excludeEnd("ctx");
-return $recv($2)._messageText_($3);
+return $recv($3)._messageText_($4);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"parseError:parsing:",{anException:anException,aString:aString,pos:pos},$globals.SmalltalkImage)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anException", "aString"],
-source: "parseError: anException parsing: aString\x0a\x09| pos |\x0a\x09pos := (anException basicAt: 'location') start.\x0a\x09^ ParseError new messageText: 'Parse error on line ', pos line ,' column ' , pos column ,' : Unexpected character ', (anException basicAt: 'found')",
+source: "parseError: anException parsing: aString\x0a\x09| pos |\x0a\x09anException isSmalltalkError ifTrue: [ ^ anException resignal ].\x0a\x09pos := (anException basicAt: 'location') start.\x0a\x09^ ParseError new messageText: 'Parse error on line ', pos line ,' column ' , pos column ,' : Unexpected character ', (anException basicAt: 'found')",
 referencedClasses: ["ParseError"],
 //>>excludeEnd("ide");
-messageSends: ["start", "basicAt:", "messageText:", "new", ",", "line", "column"]
+messageSends: ["ifTrue:", "isSmalltalkError", "resignal", "start", "basicAt:", "messageText:", "new", ",", "line", "column"]
 }),
 $globals.SmalltalkImage);
 

+ 1 - 0
src/Kernel-Infrastructure.st

@@ -942,6 +942,7 @@ asSmalltalkException: anObject
 
 parseError: anException parsing: aString
 	| pos |
+	anException isSmalltalkError ifTrue: [ ^ anException resignal ].
 	pos := (anException basicAt: 'location') start.
 	^ ParseError new messageText: 'Parse error on line ', pos line ,' column ' , pos column ,' : Unexpected character ', (anException basicAt: 'found')
 ! !