Skip to content

Commit 5348772

Browse files
authored
Merge pull request #976 from xuhuanzy/update
fix(parser): Support cond generic literals `true`, `false`, and `nil`.
2 parents 12b6ba1 + 08e9111 commit 5348772

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

crates/emmylua_code_analysis/src/compilation/test/generic_test.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,4 +816,17 @@ mod test {
816816
let result_ty = ws.expr_ty("result");
817817
assert_eq!(ws.humanize_type(result_ty), "integer");
818818
}
819+
820+
#[test]
821+
fn test_extends_true() {
822+
let mut ws = VirtualWorkspace::new();
823+
assert!(ws.check_code_for(
824+
DiagnosticCode::TypeNotFound,
825+
r#"
826+
---@alias TestA<T> T extends "test" and number or string
827+
---@alias TestB<T> T extends true and number or string
828+
---@alias TestC<T> T extends 111 and number or string
829+
"#,
830+
));
831+
}
819832
}

crates/emmylua_parser/src/lexer/lua_doc_lexer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,9 @@ impl LuaDocLexer<'_> {
688688
ch if is_name_start(ch) => {
689689
let (text, _) = read_doc_name(reader);
690690
match text {
691+
"true" => LuaTokenKind::TkTrue,
692+
"false" => LuaTokenKind::TkFalse,
693+
"nil" => LuaTokenKind::TkNil,
691694
"new" => LuaTokenKind::TkDocNew,
692695
_ => LuaTokenKind::TkName,
693696
}

0 commit comments

Comments
 (0)