Skip to content

Commit

Permalink
Throw on duplicated args (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
Smaug123 authored Sep 4, 2024
1 parent 2220f88 commit 047b2ed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions WoofWare.Myriad.Plugins/ArgParserGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ module private ParseTree =
let nonPos2, pos = accumulatorsPos tree
nonPos @ nonPos2, Some pos

|> fun (nonPos, pos) ->
let duplicateArgs =
Option.toList pos @ nonPos
|> List.map (fun pf -> pf.ArgForm)
|> List.groupBy id
|> List.choose (fun (key, v) -> if v.Length > 1 then Some key else None)

match duplicateArgs with
| [] -> nonPos, pos
| dups ->
let dups = dups |> String.concat " "
failwith $"Duplicate args detected! %s{dups}"

/// Build the return value.
let rec instantiate<'a> (tree : ParseTree<'a>) : SynExpr =
match tree with
Expand Down

0 comments on commit 047b2ed

Please sign in to comment.