File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
crates/code_analysis/src/compilation/analyzer/flow Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,46 @@ fn broadcast_up(
132132 type_assert,
133133 ) ;
134134 }
135+ BinaryOperator :: OpEq => {
136+ if origin. syntax ( ) . kind ( ) != LuaSyntaxKind :: NameExpr . into ( ) {
137+ return None ;
138+ }
139+
140+ let ( left, right) = binary_expr. get_exprs ( ) ?;
141+ let expr = if left. get_position ( ) == origin. get_position ( ) {
142+ right
143+ } else {
144+ left
145+ } ;
146+
147+ if let LuaExpr :: LiteralExpr ( literal) = expr {
148+ let type_assert = match literal. get_literal ( ) ? {
149+ LuaLiteralToken :: Nil ( _) => TypeAssertion :: NotExist ,
150+ LuaLiteralToken :: Bool ( b) => {
151+ if b. is_true ( ) {
152+ TypeAssertion :: Exist
153+ } else {
154+ TypeAssertion :: NotExist
155+ }
156+ }
157+ LuaLiteralToken :: Number ( _) => {
158+ TypeAssertion :: Force ( LuaType :: Number )
159+ }
160+ LuaLiteralToken :: String ( _) => {
161+ TypeAssertion :: Force ( LuaType :: String )
162+ }
163+ _ => return None ,
164+ } ;
165+
166+ broadcast_up (
167+ analyzer,
168+ flow_chains,
169+ binary_expr. get_parent :: < LuaAst > ( ) ?,
170+ LuaAst :: LuaBinaryExpr ( binary_expr) ,
171+ type_assert,
172+ ) ;
173+ }
174+ }
135175 _ => { }
136176 }
137177 }
You can’t perform that action at this time.
0 commit comments