Skip to content

System.Reflection.AmbiguousMatchException occurs when CLIArguments contains Tag #185

Description

@i-shm

Description

When CLIArguments contains Tag, such as:

...
[<RequireQualifiedAccess>]
type CLIArguments =
    | Version
    | [<CliPrefix(CliPrefix.None)>] Add
    | [<CliPrefix(CliPrefix.None)>] Init
    | [<CliPrefix(CliPrefix.None)>] Log
    | [<CliPrefix(CliPrefix.None)>] Rm
    | [<CliPrefix(CliPrefix.None)>] Tag // Here
    | [<CliPrefix(CliPrefix.None)>] Status
    | [<CliPrefix(CliPrefix.None)>] Cat_File
    | [<CliPrefix(CliPrefix.None)>] Check_Ignore
    | [<CliPrefix(CliPrefix.None)>] Checkout
    | [<CliPrefix(CliPrefix.None)>] Commit
    | [<CliPrefix(CliPrefix.None)>] Hash_Object
    | [<CliPrefix(CliPrefix.None)>] Ls_Files
    | [<CliPrefix(CliPrefix.None)>] Ls_Tree
    | [<CliPrefix(CliPrefix.None)>] Rev_Parse
    | [<CliPrefix(CliPrefix.None)>] Show_Ref
...

System.Reflection.AmbiguousMatchException will be thrown at runtime:
image

And if I rename the Tag to another name, it will work.

text:

Unhandled exception. System.Reflection.AmbiguousMatchException: Ambiguous match found for 'vercos.Argu+CLIArguments CLIArguments get_Tag()'.
   at System.DefaultBinder.FindMostDerivedNewSlotMeth(MethodBase[] match, Int32 cMatches)
   at System.RuntimeType.GetMethodImplCommon(String name, Int32 genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.Type.GetMethod(String name, BindingFlags bindingAttr)
   at Microsoft.FSharp.Reflection.Impl.getUnionCaseConstructorMethod(Type typ, Int32 tag, BindingFlags bindingFlags) in D:\a\_work\1\s\src\FSharp.Core\reflect.fs:line 602
   at Microsoft.FSharp.Reflection.Impl.getUnionCaseConstructorCompiled(Type typ, Int32 tag, BindingFlags bindingFlags) in D:\a\_work\1\s\src\FSharp.Core\reflect.fs:line 615
   at Microsoft.FSharp.Reflection.FSharpValue.PreComputeUnionConstructor(UnionCaseInfo unionCase, FSharpOption`1 bindingFlags) in D:\a\_work\1\s\src\FSharp.Core\reflect.fs:line 1370
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Argu.PreCompute.postProcess@648(UnionArgInfo argInfo)
   at Argu.PreCompute.checkUnionArgInfo(UnionArgInfo result)
   at <StartupCode$Argu>.$ArgumentParser.-cctor@87-1.Invoke(Unit unitVar)
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Argu.ArgumentParser`1..ctor(FSharpOption`1 programName, FSharpOption`1 helpTextMessage, FSharpOption`1 usageStringCharacterWidth, FSharpOption`1 errorHandler, FSharpOption`1 checkStructure)
   at Argu.ArgumentParser.Create[Template](FSharpOption`1 programName, FSharpOption`1 helpTextMessage, FSharpOption`1 usageStringCharacterWidth, FSharpOption`1 errorHandler, FSharpOption`1 checkStructure)
   at vercos.Argu.Parser.get_parser() in /home/muqiu-han/Workspace/vercos/vercos/Argu.fs:line 62
   at vercos.Argu.Parser.Parse(String[] argv) in /home/muqiu-han/Workspace/vercos/vercos/Argu.fs:line 64
   at vercos.Main.main(String[] argv) in /home/muqiu-han/Workspace/vercos/vercos/Program.fs:line 

Related information

  • Operating system: Linux
  • Argu Version: 6.1.1
  • .NET Core Version: 8.0.100-rc.2.23502.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions