From b19f3e794f8f9406e40b59c47056969f39f69083 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 2 Jun 2017 19:25:47 -0400 Subject: [PATCH] add error for duplicate names in a named tuple expression --- src/julia-syntax.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index cb0b773131a9f6..158ca702943eeb 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2163,11 +2163,14 @@ (if (not (every (lambda (x) (and (assignment? x) (symbol? (cadr x)))) (cdr e))) (error (string "invalid named tuple syntax \"" (deparse e) "\"")) - (expand-forms `(call (top namedtuple) - (curly (core NamedTuple) - (tuple ,@(map (lambda (x) (quotify (cadr x))) - (cdr e)))) - ,@(map caddr (cdr e))))) + (let* ((names (map cadr (cdr e))) + (dups (has-dups names))) + (if dups + (error (string "field name \"" (car dups) "\" repeated in named tuple")) + (expand-forms `(call (top namedtuple) + (curly (core NamedTuple) + (tuple ,@(map quotify names))) + ,@(map caddr (cdr e))))))) (expand-forms `(call (core tuple) ,@(cdr e))))) '=>