alecthomas / alecthomas/participle

possible bug in tag syntax

Offen
#249 4 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
3.9k
Forks
213
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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)
}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.