parser: fix type_only fns starting with varargs

pull/5295/head
spaceface777 2020-06-08 19:02:36 +02:00 committed by GitHub
parent 564545d20a
commit 30f1c6bad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -359,7 +359,7 @@ fn (mut p Parser) fn_args() ([]table.Arg, bool) {
mut args := []table.Arg{}
mut is_variadic := false
// `int, int, string` (no names, just types)
types_only := p.tok.kind in [.amp, .and] || (p.peek_tok.kind == .comma && p.table.known_type(p.tok.lit)) ||
types_only := p.tok.kind in [.amp, .and, .ellipsis] || (p.peek_tok.kind == .comma && p.table.known_type(p.tok.lit)) ||
p.peek_tok.kind == .rpar
// TODO copy pasta, merge 2 branches
if types_only {

View File

@ -0,0 +1,16 @@
// Not real external functions, so we won't call them
// We just want to make sure they compile
struct Foo {}
fn C.a(a string, b int) f32
fn C.b(a &voidptr)
fn C.c(a string, b ...string) string
fn C.d(a ...int)
fn JS.e(a string, b ...string) int
fn JS.f(a &Foo) // TODO: Should this be allowed?
fn C.g(string, ...int)
fn C.h(&int)
fn JS.i(...string)