Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msil: problems with default element-equals algorithm in Map/Set #987

Closed
scabug opened this issue May 31, 2008 · 2 comments
Closed

msil: problems with default element-equals algorithm in Map/Set #987

scabug opened this issue May 31, 2008 · 2 comments

Comments

@scabug
Copy link

scabug commented May 31, 2008

MSIL version of Scala.

I’ve run into this problem in a few different contexts. Basically it seems that in many circumstances, the default element-equality algorithm for collections wants to turn the elements into integers-- and then fails when it cannot parse string elements as ints.

For example:

import scala.collection.immutable.HashSet

object MapBug extends Application {
	
	var working = new HashSet[String]++List("A", "B")
	println("contains(A) == " + working.contains("A"))	

	// Throws an exception:
	var buggy = Set[String]("A", "B")
	println("contains(B) == " + buggy.contains("B"))	
}

Outputs:

contains(A) == True

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for MapBug$$ ---> System.FormatException: Input string was not in the correct format
  at System.Int32.Parse (System.String s, NumberStyles style, IFormatProvider fp) [0x00000] 
  at System.Int32.Parse (System.String s, IFormatProvider fp) [0x00000] 
  at System.Convert.ToInt32 (System.String value, IFormatProvider provider) [0x00000] 
  at System.String.System.IConvertible.ToInt32 (IFormatProvider provider) [0x00000] 
  at scala.runtime.Comparator.equals (System.Object a, System.Object b) [0x00000] 
  at scala.collection.immutable.Set1.contains (System.Object elem) [0x00000] 
  at scala.collection.immutable.Set1.$$plus (System.Object elem) [0x00000] 
  at scala.collection.immutable.Set$$$$anonfun$$$$plus$$plus$$1.apply (Set s, System.Object elem) [0x00000] 
  at scala.collection.immutable.Set$$$$anonfun$$$$plus$$plus$$1.apply (System.Object x$$1, System.Object x$$2) [0x00000] 
  at scala.Iterator$$class.foldLeft (Iterator $$this, System.Object z, Function2 op) [0x00000] 
  at scala.runtime.BoxedArray$$$$anon$$2.foldLeft (System.Object x$$1, Function2 x$$2) [0x00000] 
  at scala.Iterable$$class.foldLeft (Iterable $$this, System.Object z, Function2 op) [0x00000] 
  at scala.runtime.BoxedArray.foldLeft (System.Object x$$1, Function2 x$$2) [0x00000] 
  at scala.Iterable$$class.$$div$$colon (Iterable $$this, System.Object z, Function2 op) [0x00000] 
  at scala.runtime.BoxedArray.$$div$$colon (System.Object x$$1, Function2 x$$2) [0x00000] 
  at scala.collection.immutable.Set$$class.$$plus$$plus (Set $$this, Iterable elems) [0x00000] 
  at scala.collection.immutable.EmptySet.$$plus$$plus (Iterable x$$1) [0x00000] 
  at scala.collection.immutable.Set$$.apply (Seq elems) [0x00000] 
  at MapBug$$..ctor () [0x00000] 
  at MapBug$$..cctor () [0x00000] --- End of inner exception stack trace ---

  at <Module>.Main (System.String[] args) [0x00000] 

scalac-net -version
Scala compiler version 2.7.1.final -- Copyright 2002-2008, LAMP/EPFL

@scabug
Copy link
Author

scabug commented May 31, 2008

Imported From: https://issues.scala-lang.org/browse/SI-987?orig=1
Reporter: andrewf

@scabug
Copy link
Author

scabug commented May 7, 2012

@magarciaEPFL said:
The binaries and sources of Scala.NET (.exe and .dll) can be found at https://github.com/magarciaEPFL/scaladotnet
The sources for the cross-compiler at https://github.com/magarciaEPFL/scala/tree/dotnetcrosscompiler

@scabug scabug closed this as completed May 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant