File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed 
main/kotlin/org/pkl/lsp/analyzers 
test/files/DiagnosticsSnippetTests Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,13 @@ class TypeCheckAnalyzer(project: Project) : Analyzer(project) {
3131  override  fun  doAnalyze (node :  PklNode , holder :  DiagnosticsHolder ): Boolean  {
3232    if  (node !is  PklExpr ) return  true 
3333
34-     val  module =  node.enclosingModule ? :  return  true 
34+     val  module =  node.enclosingModule ? :  return  false 
3535    val  project =  module.project
3636    val  base =  project.pklBaseModule
3737    val  context =  node.containingFile.pklProject
3838
3939    val  expectedType =  node.inferExprTypeFromContext(base, mapOf (), context)
40-     if  (expectedType ==  Type .Unknown ) return  false 
40+     if  (expectedType ==  Type .Unknown ) return  true 
4141
4242    val  exprType =  node.computeExprType(base, mapOf (), context)
4343    val  exprValue =  lazy { node.toConstraintExpr(base, context).evaluate(ConstraintValue .Error ) }
Original file line number Diff line number Diff line change @@ -53,3 +53,13 @@ datasize5: DataSize(isDecimalUnit) = 5.mib
5353string1 : String(isEmpty)  = "hello" 
5454
5555string2 : String(isRegex)  = "\\ " 
56+ 
57+ typealias  MyStr  = String(matches(Regex(#"\d*"#) ))
58+ 
59+ listing1  = new  Listing<MyStr>  {
60+   "Invalid" 
61+ }
62+ 
63+ listing2 : Listing<MyStr>  = new  {
64+   "Invalid" 
65+ }
Original file line number Diff line number Diff line change 165165| Error: Constraint violation.
166166| Required: isRegex
167167| Found: "\"
168-  
168+  
169+  typealias MyStr = String(matches(Regex(#"\d*"#)))
170+  
171+  listing1 = new Listing<MyStr> {
172+    "Invalid"
173+    ^^^^^^^^^
174+ | Error: Constraint violation.
175+ | Required: matches(Regex(#"\d*"#))
176+ | Found: "Invalid"
177+  }
178+  
179+  listing2: Listing<MyStr> = new {
180+    "Invalid"
181+    ^^^^^^^^^
182+ | Error: Constraint violation.
183+ | Required: matches(Regex(#"\d*"#))
184+ | Found: "Invalid"
185+  }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments