Skip to content

Render Symbols with repr in duplicate-name error message#3533

Open
LilithHafner wants to merge 3 commits into
JuliaData:mainfrom
LilithHafner:fix-symbol-error-rendering
Open

Render Symbols with repr in duplicate-name error message#3533
LilithHafner wants to merge 3 commits into
JuliaData:mainfrom
LilithHafner:fix-symbol-error-rendering

Conversation

@LilithHafner

Copy link
Copy Markdown
Contributor

Fixes #3532

Before:

julia> DataFrame([1 2; 3 4], [Symbol("column name"), Symbol("column name")])
ERROR: ArgumentError: Duplicate variable names: :column name. Pass makeunique=true to make them unique using a suffix automatically.

After:

julia> DataFrame([1 2; 3 4], [Symbol("column name"), Symbol("column name")])
ERROR: ArgumentError: Duplicate variable names: Symbol("column name"). Pass makeunique=true to make them unique using a suffix automatically.

Three call sites updated (src/other/utils.jl and two in src/other/index.jl); no tests pin the existing error string, and the docstring example in abstractdataframe.jl uses :a, which still renders identically.


  • Co-authored-by: claude code

string.(':', sym) renders symbols containing whitespace or other
non-identifier characters ambiguously (e.g. ":column name"), making
the error read like a parse error rather than naming a single Symbol.
Switch to repr, which produces ":foo" for ordinary identifiers and
Symbol("column name") for the rest, matching what one would write
in source.

@bkamins bkamins left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. It would be good to add a test wih string column names, but it will work OK (they will be quoted in ").

@bkamins bkamins requested a review from nalimilan April 26, 2026 07:47
@bkamins

bkamins commented Apr 26, 2026

Copy link
Copy Markdown
Member

@nalimilan - looks good?

@bkamins bkamins added this to the patch milestone Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error message renders Symbol containing whitespace as :column name instead of Symbol("column name

3 participants