Origen-SDK/origen

Parameter sets now throwing errors

Closed this issue · 9 comments

Hi,

I am trying to upgrade our Origen version to 0.42.0 and I am now getting an error for previously working parameter sets. Here is an example:

[1] pry(#<Our::Interface>)> test_instance.alarms.class
=> Origen::Parameters::Set
[2] pry(#<Our::Interface>)> test_instance.alarms
=> {:on_fail=>true, :on_pass=>false}
[3] pry(#<Our::Interface>)> test_instance.alarms.on_fail
=> true
[4] pry(#<Our::Interface>)> test_instance.alarms.on_pass
NoMethodError: undefined method `on_pass' for {:on_fail=>true, :on_pass=>false}:Origen::Parameters::Set
from /users/user/origen/.origen/gems/ruby/2.3.0/bundler/gems/origen-da802b93dda1/lib/origen/parameters/set.rb:65:in `method_missing'

It seems that parameter sets now don't support false values.

thx

rlaj commented

@info-rchitect , do you know what Origen version you were running previously? I can confirm the same issue in 0.36.1.

0.34.2

@rlaj I think I found a simple fix but having issues running spec tests, stay tuned.

Here is my fix:

image

Line 64 is the culprit.

rlaj commented

Ok, looks right. So does that mean it was never really working properly and there was some subtle change to Ruby Hash method_missing that now throws an error?

@rlaj Yeah i cannot figure it out as the set.rb file looks unchanged.

ginty commented

No idea what the root cause is here either, but wondering if that really is the fix - i.e. will someone try to assign a parameter value of nil at some point?

This might be better (untested):

if !has_key?(method)
  super
else
  val = self[method]
  if val.is_a?(Set)
    # ...

@ginty @rlaj I made a slight change to the fix. Let me know if we are ready to merge.