Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/puppet-lint/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def find_resource_type_token(index)
lbrace_idx = tokens[0..index].rindex do |token|
token.type == :LBRACE && token.prev_code_token.type != :QMARK
end

raise PuppetLint::SyntaxError, tokens[index] if lbrace_idx.nil?

tokens[lbrace_idx].prev_code_token
end

Expand Down
12 changes: 12 additions & 0 deletions spec/puppet-lint/data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
}
end
end

context 'when typo in namespace separator makes parser look for resource' do
let(:manifest) { '$testparam = $::module:;testparam' }

it 'raises a SyntaxError' do
expect {
data.resource_indexes
}.to raise_error(PuppetLint::SyntaxError) { |error|
expect(error.token).to eq(data.tokens[5])
}
end
end
end

describe '.insert' do
Expand Down