Skip to content

Commit 635af15

Browse files
committed
assign more source sections
1 parent 3005b36 commit 635af15

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/ExpressionNode.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import com.oracle.truffle.api.instrumentation.Tag;
5050
import com.oracle.truffle.api.nodes.NodeCost;
5151
import com.oracle.truffle.api.nodes.UnexpectedResultException;
52+
import com.oracle.truffle.api.source.SourceSection;
5253

5354
/**
5455
* Base class for all expressions. Expressions always return a value.
@@ -141,7 +142,11 @@ public static final class ExpressionWithSideEffects extends ExpressionNode {
141142
private ExpressionWithSideEffects(ExpressionNode node, StatementNode sideEffect) {
142143
this.node = node;
143144
this.sideEffect = sideEffect;
144-
this.assignSourceSection(node.getSourceSection());
145+
SourceSection sourceSection = node.getSourceSection();
146+
if (sourceSection == null) {
147+
sourceSection = sideEffect.getSourceSection();
148+
}
149+
this.assignSourceSection(sourceSection);
145150
}
146151

147152
@Override

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/PythonTreeTranslator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ private SourceSection deriveSourceSection(RuleNode node) {
227227
public Object visitFile_input(Python3Parser.File_inputContext ctx) {
228228
environment.enterScope(ctx.scope);
229229
ExpressionNode file = asExpression(super.visitFile_input(ctx));
230+
deriveSourceSection(ctx, file);
230231
environment.leaveScope();
231232
return factory.createModuleRoot(name, file, ctx.scope.getFrameDescriptor());
232233
}
@@ -247,6 +248,7 @@ public Object visitEval_input(Python3Parser.Eval_inputContext ctx) {
247248
public Object visitSingle_input(Python3Parser.Single_inputContext ctx) {
248249
environment.enterScope(ctx.scope);
249250
ExpressionNode body = asExpression(super.visitSingle_input(ctx));
251+
deriveSourceSection(ctx, body);
250252
environment.leaveScope();
251253
if (isInlineMode) {
252254
return body;

0 commit comments

Comments
 (0)