alecthomas / alecthomas/participle

possible bug in tag syntax

Open
#249 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
3.9k
Forks
213
PR merge metrics
No merged PRs in 30d

Description

Hello,

it seems there is a difference between the "raw" and "parse" tag syntax? The following repro shows what I stumbled upon.

```go
package tagsyntax

import (
"testing"

"github.com/alecthomas/assert/v2"
"github.com/alecthomas/participle/v2"
)

type GoodAST struct {
Key string `parser:"@Ident '='"`
BlankLines []string `"\n"`
}

type BadAST struct {
Key string `parser:"@Ident '='"`
// Same as field in GoodAST, as explained in https://github.com/alecthomas/participle#tag-syntax
BlankLines []string `parser:"'\n'"`
}

func TestLiteralNotTerminatedGood(t *testing.T) {
_, err := participle.Build(&GoodAST{})

assert.NoError(t, err)
}

func TestLiteralNotTerminatedBad(t *testing.T) {
_, err := participle.Build(&BadAST{})

// The error is:
//
// Key: :1:2: literal not terminated
//
// which is confusing because it refers to the previous field in the struct (Key)
// and unclear?
assert.NoError(t, err)
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.