Free cookie consent management tool by TermsFeed Policy Generator

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1678 closed defect (worksforme)

Assigning null to a LookupParameter throws an exception

Reported by: abeham Owned by: swagner
Priority: high Milestone:
Component: Parameters Version: 3.3.5
Keywords: Cc:

Description

Line 153 in LookupParameter.cs checks if the type being assigned to the ActualValue is a compatible type:

    protected override void SetActualValue(IItem value) {
      if (!(value is T))
        throw new InvalidOperationException(
          string.Format("Type mismatch. Value is not a \"{0}\".",
                        typeof(T).GetPrettyName())
        );

However, the condition is always false when value is null. Is this by design or is it a bug?

Change History (3)

comment:1 Changed 12 years ago by swagner

When I designed the LookupParameter type, I was not able to identify any reasonable use case which requires to assign a null value. Therefore this behavior is by design. However, if it turns out now that we require the assignment of null values to LookupParameters, this should be fixed.

comment:2 Changed 12 years ago by abeham

  • Resolution set to worksforme
  • Status changed from new to closed

As of now this change is not necessary, my requirement was to store an operator state in the scope tree where null denoted the "initial state" or "no state" case. Such a behavior is also possible with an extra Boolean parameter. swagner stated that it was unclear if assigning null meant that the variable was to be deleted or whether to just set the value to null and it isn't certain if null variables are correctly handled across the application (ResultsCollector, Views, etc.).

comment:3 Changed 12 years ago by abeham

  • Milestone HeuristicLab 3.3.x Backlog deleted
Note: See TracTickets for help on using tickets.