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

Erroneous duplicate value warning #2122

Closed
disarray2077 opened this issue Jan 31, 2025 · 1 comment
Closed

Erroneous duplicate value warning #2122

disarray2077 opened this issue Jan 31, 2025 · 1 comment

Comments

@disarray2077
Copy link
Contributor

When compiling the code below, the compiler incorrectly reports duplicate values in the IndexerMethods enum, even though no duplicates are present.

using System;
using System.Collections;

namespace simple_test;

class Program
{
	struct Yes;
	struct No;

	struct IsIndexable<T, TKey>
	{
		public typealias Result = comptype(_isIndexable(typeof(T), typeof(TKey)));

		private enum IndexerMethods
		{
			Undefined = 0,
			Get = 1,
			Set = 2,
			GetSet = Get | Set
		}

		[Comptime]
		private static Type _isIndexable(Type type, Type keyType)
		{
			IndexerMethods m = .();
			return typeof(No);
		}
	}

	class ClassInstanceWrapper<T>
		where IsIndexable<T, int>.Result : No
	{
	}

	static void Main ()
	{
		let c1 = scope ClassInstanceWrapper<List<int>>();
		Console.WriteLine(c1);
	}
}

Tested with: 206023f

@bfiete
Copy link
Collaborator

bfiete commented Jan 31, 2025

Fixed at 03f5c41

@bfiete bfiete closed this as completed Jan 31, 2025
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

2 participants