File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1110,6 +1110,10 @@ func (p *parser) parseTypeAtom() *TypeExpr {
11101110 ty .Nullable = nullable
11111111
11121112 if p .peekToken .Type == tokenLT {
1113+ if ty .Kind != TypeArray && ty .Kind != TypeHash {
1114+ p .addParseError (p .curToken .Pos , fmt .Sprintf ("type %s does not accept type arguments" , ty .Name ))
1115+ return nil
1116+ }
11131117 p .nextToken ()
11141118 p .nextToken ()
11151119 typeArgs := []* TypeExpr {}
Original file line number Diff line number Diff line change @@ -138,3 +138,18 @@ end`
138138 t .Fatalf ("expected nullable string type, got %#v" , second .Type )
139139 }
140140}
141+
142+ func TestParserTypeSyntaxRejectsGenericArgsOnScalars (t * testing.T ) {
143+ source := `def run(value: int<string>)
144+ value
145+ end`
146+
147+ p := newParser (source )
148+ _ , errs := p .ParseProgram ()
149+ if len (errs ) == 0 {
150+ t .Fatalf ("expected parse errors" )
151+ }
152+ if got := errs [0 ].Error (); ! strings .Contains (got , "type int does not accept type arguments" ) {
153+ t .Fatalf ("unexpected parse error: %s" , got )
154+ }
155+ }
You can’t perform that action at this time.
0 commit comments