fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

Infinite loop when comparing a unit of measure abbreviation with another type #395

Open mlaily opened 1 year ago

mlaily commented 1 year ago

Description

While working on FSharp.Data, I noticed that comparing a UoM abbreviation type with a IJsonDocument type causes an infinite recursion/loop.

Repro steps

On FSharp.Data, I triggered this with the JsonProvider and an inline schema containing an abbreviated UoM:

type InlineSchemas = JsonProvider<""" {"a": "typeof<int<m>>"} """, InferenceMode=InferenceMode.ValuesAndInlineSchemasOverrides>

image

Note the lack of full syntactic colorization, since the IDE is caught in the loop.

Known workarounds

Replacing m with metre works: no infinite loop.

EDIT: ah it seems I was just lucky to pick one that was not in the list!
After completing the list in this PR https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/394, metre is now considered as a FSharpTypeAbbreviation, and the equality check loops the same way as with m! :/

Related information

I tried updating the github commit of the SDK referenced by FSharp.Data, but the problem still exists.

I'm not sure how to fix it, but in case it helps, here are a few screenshots of the looping methods:

image

image

image

And back to square one: image

mlaily commented 1 year ago

I'd appreciate any pointer about how to fix that :)