Opened 3 months ago

#2723 new defect

Providing variable values as double[] to Dataset fails at runtime

Reported by: abeham Owned by:
Priority: medium Milestone: HeuristicLab 3.3.15
Component: Problems.DataAnalysis Version: 3.3.14
Keywords: Cc:

Description

In the Dataset class an IList is accepted as variable values, however later on this IList is cast as a List<T>.

public Dataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues)
  : base() {
}

  // line 199:
  List<T> values = list as List<T>;
  if (values == null) throw new ArgumentException("The variable " + variableName + " is not a " + typeof(T) + " variable.");

Now, a double[] is an IList, but not a List<double>. The compiler is happy, but the program crashes at runtime. In my opinion, it should be checked if it's a T[] in case List<T> fails or otherwise prevent accepting double[] in the constructor.

Change History (0)

Note: See TracTickets for help on using tickets.