bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

sourceName in SourcePos is not always the expected culprit #184

Open PierreR opened 8 years ago

PierreR commented 8 years ago

Given a file called 'saltmaster.pp' containing these lines:

  class {
    'application::profile::puppetmaster::environments':
      evironments => $environments
  }

where I simulate an error ('evironmentsinstead ofenvironment`), I receive the following error message:

x saltmaster_dev
  The following parameters are unknown: (evironments) when including class application::profile::puppetmaster::environments at # SourcePos {sourceName = "./modules/application/manifests/profile/puppetmaster/environments.pp", sourceLine = Pos 4, sourceColumn = Pos 1}

Is is rather an inconvenience that the sourcePos describes the error as happening in the including class rather than where the error is actually happening.

Is there a quick fix for this ?

As a bit of context, I have created a shake file for checking all my catalogues. In case of error, I ideally would set the shake need (the dependencies) onto the culprit file only. The first 'headache' with this is that language-puppet does not expose a structure Error type, just a Doc PrettyError. Then the second issue is the return SourcePos as explain above.

bartavelle commented 8 years ago

I don't think it's easy to fix it properly. This is one of the most tangled parts of the code, as the "current position" is kept in the state monad. IIRC, it used to work as you expected, but then another error message was not at the right place ... I'll look into it anyway.

PierreR commented 8 years ago

It is neither urgent or such a big deal for me.