diff --git a/src/parser.cc b/src/parser.cc index 2de42cc..e293ebc 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -2677,7 +2677,7 @@ ast::c_type parse_type( { lex_state ls{L, input, iend, PARSE_MODE_NOTCDEF, paridx}; ast::c_type tp{}; - if (!ls.get() || !parse_type(ls, tp)) { + if (!ls.get() || !parse_type(ls, tp) || !check(ls, -1)) { if (ls.err_token() > 0) { char buf[16]; lua_pushfstring( diff --git a/tests/istype.lua b/tests/istype.lua index e67e7fd..49107e2 100644 --- a/tests/istype.lua +++ b/tests/istype.lua @@ -36,3 +36,12 @@ assert(not ffi.istype("int &", ffi.typeof("float &"))) -- second argument must be a cval assert(not ffi.istype("int", "int")) assert(not ffi.istype("int", true)) + +-- types in typeof must be terminated +local ret, msg = pcall(ffi.typeof, "long int bla") +assert(not ret) +assert(msg == "'' expected near ''") + +local ret, msg = pcall(ffi.typeof, "long int int") +assert(not ret) +assert(msg == "'' expected near 'int'")