Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: unclear whether # is a valid identifier #3816

Open
mvdan opened this issue Mar 13, 2025 · 0 comments
Open

spec: unclear whether # is a valid identifier #3816

mvdan opened this issue Mar 13, 2025 · 0 comments
Labels
spec-deviation Bugs where the implementation does not follow the spec.

Comments

@mvdan
Copy link
Member

mvdan commented Mar 13, 2025

A hash just by itself is not a valid identifier per the spec:

https://cuelang.org/docs/reference/spec/#identifiers

identifier = [ "#" | "_#" ] letter { letter | unicode_digit } .

However, as of 2d28bd3, they clearly work in the current implementation:

exec cue export input.cue

-- input.cue --
#: "foo"
bar: #
> exec cue export input.cue
[stdout]
{
    "bar": "foo"
}

Moreover, they get used by the jsonschema encoding as well:

exec cue def input.json

-- input.json --
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$defs": {
        "some-thing": {
            "type": "string"
        }
    }
}
> exec cue def input.json
[stdout]
@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
_
#: {
	"some-thing": string
}

It may be too late or painful to remove support for hash identifiers at this point, if we never intended them to work. The easier alternative seems to be to adjust the spec to reflect reality. cc @rogpeppe

@mvdan mvdan added the spec-deviation Bugs where the implementation does not follow the spec. label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec-deviation Bugs where the implementation does not follow the spec.
Projects
None yet
Development

No branches or pull requests

1 participant