Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Compiler#error() to produce correct line numbers on dyanimc require
errors
  • Loading branch information
adambeynon committed Dec 18, 2013
1 parent cfc5028 commit deb05d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions lib/opal/compiler.rb
Expand Up @@ -53,7 +53,6 @@ def self.compiler_option(name, default_value, mid = nil)
attr_reader :eof_content

def initialize
@line = 1
@indent = ''
@unique = 0
@options = {}
Expand Down Expand Up @@ -90,15 +89,15 @@ def method_calls
# This is called when a parsing/processing error occurs. This
# method simply appends the filename and curent line number onto
# the message and raises it.
def error(msg)
raise SyntaxError, "#{msg} :#{file}:#{@line}"
def error(msg, line = nil)
raise SyntaxError, "#{msg} :#{file}:#{line}"
end

# This is called when a parsing/processing warning occurs. This
# method simply appends the filename and curent line number onto
# the message and issues a warning.
def warning(msg)
warn "#{msg} :#{file}:#{@line}"
def warning(msg, line = nil)
warn "#{msg} :#{file}:#{line}"
end

# Instances of `Scope` can use this to determine the current
Expand Down
4 changes: 2 additions & 2 deletions lib/opal/nodes/call.rb
Expand Up @@ -178,9 +178,9 @@ def handle_part(sexp)
msg = "Cannot handle dynamic require"
case @compiler.dynamic_require_severity
when :error
@compiler.error msg
@compiler.error msg, @sexp.line
when :warning
@compiler.warning msg
@compiler.warning msg, @sexp.line
end
end

Expand Down

0 comments on commit deb05d4

Please sign in to comment.