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

Primative Bug #185

Open
VBAndCs opened this issue Oct 29, 2021 · 1 comment
Open

Primative Bug #185

VBAndCs opened this issue Oct 29, 2021 · 1 comment

Comments

@VBAndCs
Copy link

VBAndCs commented Oct 29, 2021

While working on my Small Visual Basic, I discovered a bug in the Microsoft.SmallBasic.Library.Primitive class.
When I call Primitive.IsArray on a variable that has a numeric value, it reserts its value to null. Tracing this bug, I found that IsArray calls ConstructArrayMap(), which initializes the _arrayMap:
_arrayMap = new Dictionary<Primitive, Primitive>(PrimitiveComparer.Instance);
before calling AsString
char[] source = AsString.ToCharArray();
Un the AsString if _arrayMap is not null, the primative value is set to the string representaion of the array which is null:

		if (_arrayMap != null)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (KeyValuePair<Primitive, Primitive> item in _arrayMap)
			{
				stringBuilder.AppendFormat("{0}={1};", Escape(item.Key), Escape(item.Value));
			}
			_primitive = stringBuilder.ToString();
		}
@VBAndCs
Copy link
Author

VBAndCs commented Oct 29, 2021

A possible fix is to make the _arrayMap check an elseif to be ignored if the promative has a numeric value

		elseif (_arrayMap != null)
		{

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