mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			464 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			464 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
// This has to work without linking, because everything will be inlined.
 | 
						|
library L {
 | 
						|
    struct S {
 | 
						|
        uint256[] data;
 | 
						|
    }
 | 
						|
 | 
						|
    function f(S memory _s) internal {
 | 
						|
        _s.data[3] = 2;
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
contract C {
 | 
						|
    using L for L.S;
 | 
						|
 | 
						|
    function f() public returns (uint256) {
 | 
						|
        L.S memory x;
 | 
						|
        x.data = new uint256[](7);
 | 
						|
        x.data[3] = 8;
 | 
						|
        x.f();
 | 
						|
        return x.data[3];
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
// ====
 | 
						|
// compileViaYul: also
 | 
						|
// ----
 | 
						|
// f() -> 2
 |