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

Sort numeric symbols #690

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

@jakebailey mentioned this is something the team is considering to do.

# Conflicts:
#	testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccessConstraint.types
#	testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccessConstraint.types.diff
#	testdata/baselines/reference/submodule/compiler/objectLiteralIndexerErrors.types.diff
#	testdata/baselines/reference/submodule/compiler/objectLiteralIndexers.types.diff
#	testdata/baselines/reference/submodule/compiler/propertiesAndIndexers.types.diff
#	testdata/baselines/reference/submodule/conformance/objectTypeWithStringNamedNumericProperty.types.diff
@@ -628,6 +629,17 @@ func (c *Checker) compareSymbolsWorker(s1, s2 *ast.Symbol) int {
if s2 == nil {
return -1
}
int1, err1 := strconv.Atoi(s1.Name)
int2, err2 := strconv.Atoi(s2.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it's not that simple. Consider symbols named "0", "00", and "000" and so on! We'd want a check that the symbol round-trips as a number. Which unfortunately is a more expensive check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I can implement that - as long as it's even something you'd like to see getting in. At the moment, the main user-oriented improvement in this is a better error message here: testdata/baselines/reference/submodule/conformance/arityAndOrderCompatibility01.errors.txt. But at the same time, this test case isn't exercising a particularly popular pattern.

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

Successfully merging this pull request may close these issues.

2 participants