Allow "bare" dynamic attrs
Now, in addition to a."${b}".c, you can write a.${b}.c (applicable
wherever dynamic attributes are valid).
Signed-off-by: Shea Levy <shea@shealevy.com>
			
			
This commit is contained in:
		
							parent
							
								
									e640d67144
								
							
						
					
					
						commit
						f9913f4422
					
				
					 4 changed files with 21 additions and 0 deletions
				
			
		|  | @ -117,6 +117,8 @@ or          { return OR_KW; } | |||
|               return INT; | ||||
|             } | ||||
| 
 | ||||
| \$\{        { return DOLLAR_CURLY; } | ||||
| 
 | ||||
| \"          { BEGIN(STRING); return '"'; } | ||||
| <STRING>([^\$\"\\]|\$[^\{\"]|\\.)+ { | ||||
|               /* !!! Not quite right: we want a follow restriction on | ||||
|  |  | |||
|  | @ -509,6 +509,7 @@ attr | |||
| 
 | ||||
| string_attr | ||||
|   : '"' string_parts '"' { $$ = $2; } | ||||
|   | DOLLAR_CURLY expr '}' { $$ = $2; } | ||||
|   ; | ||||
| 
 | ||||
| expr_list | ||||
|  |  | |||
							
								
								
									
										1
									
								
								tests/lang/eval-okay-dynamic-attrs-bare.exp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/lang/eval-okay-dynamic-attrs-bare.exp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| { binds = true; hasAttrs = true; multiAttrs = true; recBinds = true; selectAttrs = true; selectOrAttrs = true; } | ||||
							
								
								
									
										17
									
								
								tests/lang/eval-okay-dynamic-attrs-bare.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/lang/eval-okay-dynamic-attrs-bare.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| let | ||||
|   aString = "a"; | ||||
| 
 | ||||
|   bString = "b"; | ||||
| in { | ||||
|   hasAttrs = { a.b = null; } ? ${aString}.b; | ||||
| 
 | ||||
|   selectAttrs = { a.b = true; }.a.${bString}; | ||||
| 
 | ||||
|   selectOrAttrs = { }.${aString} or true; | ||||
| 
 | ||||
|   binds = { ${aString}."${bString}c" = true; }.a.bc; | ||||
| 
 | ||||
|   recBinds = rec { ${bString} = a; a = true; }.b; | ||||
| 
 | ||||
|   multiAttrs = { ${aString} = true; ${bString} = false; }.a; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue