anza-xyz / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
3 stars 3 forks source link

Compiler fails while translating Constant::Vector #49

Open jcivlin opened 5 months ago

jcivlin commented 5 months ago

In this function fn constant(&self, mc: &sbc::Constant, vec_mty: Option<&mty::Type>) -> llvm::Constant we hit this condition:

                let aval = match elt_mty {
                    _ if elt_mty.is_number() || elt_mty.is_bool() => {
                        let vals = self.rewrap_vec_constant(val_vec);
                        llcx.const_array(&vals, self.module_cx.to_llvm_type(&elt_mty, &[]).unwrap())
                    }
                    Type::Vector(bt) if bt.is_number_u8() => {
                        // This is a Constant::ByteArray element type.
                        assert!(matches!(val_vec[0], Constant::ByteArray(_)));
                        todo!("{:?}", mc);
                    }

To reproduce compile Move provided example:

 /home/sol/work/git/sui-solana-032024/external-crates/move/target/debug/move-mv-llvm-compiler -c tests/flash_lender_tests.move -p /home/sol/work/git/sui-solana-032024/sui_programmability/examples/defi/Move.toml --test -o ~/tmp/defi

Notice that some modules will be built:

 sol@dev-equinix-new-york-2:~/work/git/sui-solana-032024/sui_programmability/examples/defi:solana $% u+6$ ll ~/tmp/defi/
total 40
drwxr-xr-x  2 sol users  4096 May 29 01:26 ./
drwxr-xr-x 42 sol users  4096 May 29 01:26 ../
-rw-r--r--  1 sol users  2520 May 29 01:26 0x1__bcs.ll
-rw-r--r--  1 sol users  2536 May 29 01:26 0x1__unit_test.ll
-rw-r--r--  1 sol users  3036 May 29 01:26 0x1__vector.ll
-rw-r--r--  1 sol users 10992 May 29 01:26 0x2__tx_context.ll
-rw-r--r--  1 sol users  5167 May 29 01:26 solana_entrypoint.ll