Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created November 10, 2016 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasterDuke17/8bf6eb8c1d205426fe0acd1d5042ce79 to your computer and use it in GitHub Desktop.
Save MasterDuke17/8bf6eb8c1d205426fe0acd1d5042ce79 to your computer and use it in GitHub Desktop.
weird nqp error
diff --git a/src/vm/moar/QAST/QASTCompilerMAST.nqp b/src/vm/moar/QAST/QASTCompilerMAST.nqp
index b05ea54..a3b661f 100644
--- a/src/vm/moar/QAST/QASTCompilerMAST.nqp
+++ b/src/vm/moar/QAST/QASTCompilerMAST.nqp
@@ -1402,9 +1402,17 @@ my class MASTCompilerInstance {
# Annotate with line number if we have one.
my $node := $_.node;
if nqp::isconcrete($node) && nqp::can($node,'orig') {
- my $line := HLL::Compiler.lineof($node.orig(), $node.from(), :cache(1));
+ my str $target := ~Snode.orig();
+ my int $pos := $node.from();
+ my $file := $!file;
+ my $sf_index_s := nqp::rindex($target, '#line 1 ', $pos);
+ if $sf_index_s >= 0 {
+ $file := nqp::substr($target, $sf_index_s, nqp::index($target, "\n", $sf_index_s) - $sf_index_s);
+ nqp::printfh(nqp::getstderr(), "file: $file\n");
+ }
+ my $line := HLL::Compiler.lineof($target, $pos, :cache(1));
nqp::push(@all_ins, MAST::Annotated.new(
- :$!file, :$line, :instructions($last_stmt.instructions) ));
+ :$file, :$line, :instructions($last_stmt.instructions) ));
}
else {
nqp::splice(@all_ins, $last_stmt.instructions, +@all_ins, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment