فهرست منبع

Add option to change substrate address type

Signed-off-by: Sean Young <sean@mess.org>
Sean Young 4 سال پیش
والد
کامیت
620438c7ca
38فایلهای تغییر یافته به همراه693 افزوده شده و 538 حذف شده
  1. 4 0
      docs/running.rst
  2. 1 1
      src/abi/mod.rs
  3. 26 1
      src/bin/solang.rs
  4. 1 2
      src/codegen/cfg.rs
  5. 3 3
      src/codegen/expression.rs
  6. 1 1
      src/codegen/statements.rs
  7. 1 1
      src/codegen/strength_reduce.rs
  8. 3 3
      src/emit/mod.rs
  9. 20 16
      src/lib.rs
  10. 2 2
      src/linker/wasm.rs
  11. 10 10
      src/sema/builtin.rs
  12. 2 2
      src/sema/expression.rs
  13. 1 1
      src/sema/functions.rs
  14. 13 1
      src/sema/mod.rs
  15. 2 2
      tests/substrate.rs
  16. 34 34
      tests/substrate_tests/arrays.rs
  17. 27 27
      tests/substrate_tests/builtins.rs
  18. 17 17
      tests/substrate_tests/calls.rs
  19. 21 21
      tests/substrate_tests/contracts.rs
  20. 5 5
      tests/substrate_tests/enums.rs
  21. 43 27
      tests/substrate_tests/events.rs
  22. 12 12
      tests/substrate_tests/expressions.rs
  23. 1 1
      tests/substrate_tests/first.rs
  24. 9 9
      tests/substrate_tests/format.rs
  25. 18 18
      tests/substrate_tests/function_types.rs
  26. 56 50
      tests/substrate_tests/functions.rs
  27. 100 20
      tests/substrate_tests/imports.rs
  28. 79 76
      tests/substrate_tests/inheritance.rs
  29. 16 16
      tests/substrate_tests/libraries.rs
  30. 1 1
      tests/substrate_tests/loops.rs
  31. 10 10
      tests/substrate_tests/mappings.rs
  32. 17 17
      tests/substrate_tests/modifier.rs
  33. 34 34
      tests/substrate_tests/primitives.rs
  34. 11 11
      tests/substrate_tests/strings.rs
  35. 13 13
      tests/substrate_tests/structs.rs
  36. 27 27
      tests/substrate_tests/tags.rs
  37. 20 20
      tests/substrate_tests/value.rs
  38. 32 26
      tests/substrate_tests/variables.rs

+ 4 - 0
docs/running.rst

@@ -32,6 +32,10 @@ Options:
   This takes one argument, which can either be ``solana``, ``substrate``, or ``ewasm``. The target
   must be specified.
 
+\\-\\-address\-length *length-in-bytes*
+  Change the default address length on Substrate. By default, Substate uses an address of 32 bytes. This option
+  is ignored for any other target.
+
 \\-\\-doc
   Generate documentation for the given Solidity files as a single html page. This uses the
   doccomment tags. The result is saved in ``soldoc.html``. See :ref:`tags` for

+ 1 - 1
src/abi/mod.rs

@@ -11,7 +11,7 @@ pub fn generate_abi(
     verbose: bool,
 ) -> (String, &'static str) {
     match ns.target {
-        Target::Substrate => {
+        Target::Substrate { .. } => {
             if verbose {
                 eprintln!(
                     "info: Generating Substrate ABI for contract {}",

+ 26 - 1
src/bin/solang.rs

@@ -68,6 +68,13 @@ fn main() {
                 .possible_values(&["solana", "substrate", "ewasm"])
                 .required(true),
         )
+        .arg(
+            Arg::with_name("ADDRESS_LENGTH")
+                .help("Address length on Substrate")
+                .long("address-length")
+                .takes_value(true)
+                .default_value("32"),
+        )
         .arg(
             Arg::with_name("STD-JSON")
                 .help("mimic solidity json output on stdout")
@@ -147,13 +154,31 @@ fn main() {
         )
         .get_matches();
 
+    let address_length = matches.value_of("ADDRESS_LENGTH").unwrap();
+
+    let address_length = match address_length.parse() {
+        Ok(len) if (4..1024).contains(&len) => len,
+        _ => {
+            eprintln!("error: address length ‘{}’ is not valid", address_length);
+            std::process::exit(1);
+        }
+    };
+
     let target = match matches.value_of("TARGET") {
         Some("solana") => solang::Target::Solana,
-        Some("substrate") => solang::Target::Substrate,
+        Some("substrate") => solang::Target::Substrate { address_length },
         Some("ewasm") => solang::Target::Ewasm,
         _ => unreachable!(),
     };
 
+    if !target.is_substrate() && matches.occurrences_of("ADDRESS_LENGTH") > 0 {
+        eprintln!(
+            "error: address length cannot be modified for target ‘{}’",
+            target
+        );
+        std::process::exit(1);
+    }
+
     if matches.is_present("LANGUAGESERVER") {
         languageserver::start_server(target);
     }

+ 1 - 2
src/codegen/cfg.rs

@@ -15,7 +15,6 @@ use crate::sema::ast::{
 };
 use crate::sema::contracts::{collect_base_args, visit_bases};
 use crate::sema::symtable::Symtable;
-use crate::Target;
 
 pub type Vars = HashMap<usize, Variable>;
 
@@ -1300,7 +1299,7 @@ fn function_cfg(
     }
 
     cfg.ty = func.ty;
-    cfg.nonpayable = if ns.target == Target::Substrate {
+    cfg.nonpayable = if ns.target.is_substrate() {
         !func.is_constructor() && !func.is_payable()
     } else {
         !func.is_payable()

+ 3 - 3
src/codegen/expression.rs

@@ -859,7 +859,7 @@ pub fn expression(
                 &Type::Bool,
             );
 
-            if ns.target == Target::Substrate {
+            if ns.target.is_substrate() {
                 cfg.add(
                     vartab,
                     Instr::ValueTransfer {
@@ -892,7 +892,7 @@ pub fn expression(
             let address = expression(&args[0], cfg, contract_no, func, ns, vartab);
             let value = expression(&args[1], cfg, contract_no, func, ns, vartab);
 
-            if ns.target == Target::Substrate {
+            if ns.target.is_substrate() {
                 cfg.add(
                     vartab,
                     Instr::ValueTransfer {
@@ -1069,7 +1069,7 @@ pub fn expression(
         }
         // The Substrate gas price builtin takes an argument; the others do not
         Expression::Builtin(loc, _, Builtin::Gasprice, expr)
-            if expr.len() == 1 && ns.target != Target::Substrate =>
+            if expr.len() == 1 && !ns.target.is_substrate() =>
         {
             let ty = Type::Value;
             let gasprice = Expression::Builtin(*loc, vec![ty.clone()], Builtin::Gasprice, vec![]);

+ 1 - 1
src/codegen/statements.rs

@@ -513,7 +513,7 @@ pub fn statement(
             let mut topics = Vec::new();
             let mut topic_tys = Vec::new();
 
-            if !event.anonymous && ns.target != crate::Target::Substrate {
+            if !event.anonymous && !ns.target.is_substrate() {
                 let mut hasher = Keccak::v256();
                 hasher.update(event.signature.as_bytes());
                 let mut hash = [0u8; 32];

+ 1 - 1
src/codegen/strength_reduce.rs

@@ -1772,7 +1772,7 @@ fn test_highest_bit() {
 
 #[test]
 fn expresson_known_bits() {
-    let ns = Namespace::new(crate::Target::Substrate, 32, 16);
+    let ns = Namespace::new(crate::Target::Substrate { address_length: 32 });
     let loc = crate::parser::pt::Loc(0, 0, 0);
 
     let mut vars: Variables = HashMap::new();

+ 3 - 3
src/emit/mod.rs

@@ -3941,7 +3941,7 @@ pub trait TargetRuntime<'a> {
                                 )
                                 .into_int_value();
 
-                            let selector = if ns.target == Target::Substrate {
+                            let selector = if ns.target.is_substrate() {
                                 *selector
                             } else {
                                 selector.to_be()
@@ -5219,7 +5219,7 @@ impl<'a> Binary<'a> {
         math_overflow_check: bool,
     ) -> Self {
         match ns.target {
-            Target::Substrate => substrate::SubstrateTarget::build(
+            Target::Substrate { .. } => substrate::SubstrateTarget::build(
                 context,
                 contract,
                 ns,
@@ -6253,7 +6253,7 @@ fn load_stdlib<'a>(context: &'a Context, target: &Target) -> Module<'a> {
             .unwrap();
     }
 
-    if Target::Substrate == *target {
+    if let Target::Substrate { .. } = *target {
         let memory = MemoryBuffer::create_from_memory_range(SUBSTRATE_IR, "substrate");
 
         module

+ 20 - 16
src/lib.rs

@@ -18,12 +18,12 @@ use sema::diagnostics;
 use std::fmt;
 
 /// The target chain you want to compile Solidity for.
-#[derive(PartialEq, Clone, Copy)]
+#[derive(Clone, Copy)]
 pub enum Target {
     /// Solana, see <https://solana.com/>
     Solana,
     /// Parity Substrate, see <https://substrate.dev/>
-    Substrate,
+    Substrate { address_length: usize },
     /// Ethereum ewasm, see <https://github.com/ewasm/design>
     Ewasm,
 }
@@ -32,12 +32,28 @@ impl fmt::Display for Target {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
             Target::Solana => write!(f, "solana"),
-            Target::Substrate => write!(f, "Substrate"),
+            Target::Substrate { .. } => write!(f, "Substrate"),
             Target::Ewasm => write!(f, "ewasm"),
         }
     }
 }
 
+impl PartialEq for Target {
+    fn eq(&self, other: &Self) -> bool {
+        match self {
+            Target::Solana => matches!(other, Target::Solana),
+            Target::Substrate { .. } => matches!(other, Target::Substrate { .. }),
+            Target::Ewasm => matches!(other, Target::Ewasm),
+        }
+    }
+}
+
+impl Target {
+    pub fn is_substrate(&self) -> bool {
+        matches!(self, Target::Substrate { .. })
+    }
+}
+
 /// Compile a solidity file to list of wasm files and their ABIs. The filename is only used for error messages;
 /// the contents of the file is provided in the `src` argument.
 ///
@@ -105,19 +121,7 @@ pub fn parse_and_resolve(
     resolver: &mut FileResolver,
     target: Target,
 ) -> ast::Namespace {
-    let mut ns = ast::Namespace::new(
-        target,
-        match target {
-            Target::Ewasm => 20,
-            Target::Substrate => 32,
-            Target::Solana => 32,
-        },
-        if target == Target::Solana {
-            8 // lamports is u64
-        } else {
-            16 // value is 128 bits
-        },
-    );
+    let mut ns = ast::Namespace::new(target);
 
     match resolver.resolve_file(None, filename) {
         Err(message) => {

+ 2 - 2
src/linker/wasm.rs

@@ -33,7 +33,7 @@ pub fn link(input: &[u8], name: &str, target: Target) -> Vec<u8> {
             command_line.push(CString::new("--export").unwrap());
             command_line.push(CString::new("main").unwrap());
         }
-        Target::Substrate => {
+        Target::Substrate { .. } => {
             command_line.push(CString::new("--export").unwrap());
             command_line.push(CString::new("deploy").unwrap());
             command_line.push(CString::new("--export").unwrap());
@@ -86,7 +86,7 @@ pub fn link(input: &[u8], name: &str, target: Target) -> Vec<u8> {
 
                     *imports[ind].module_mut() = module_name.to_owned();
                 }
-                Target::Substrate => {
+                Target::Substrate { .. } => {
                     if imports[ind].field().starts_with("seal") {
                         *imports[ind].module_mut() = "seal0".to_owned();
                     }

+ 10 - 10
src/sema/builtin.rs

@@ -87,7 +87,7 @@ static BUILTIN_FUNCTIONS: [Prototype; 24] = [
         name: "selfdestruct",
         args: &[Type::Address(true)],
         ret: &[Type::Unreachable],
-        target: &[Target::Ewasm, Target::Substrate],
+        target: &[Target::Ewasm, Target::Substrate { address_length: 0 }],
         doc: "Destroys current account and deposits any remaining balance to address",
         constant: false,
     },
@@ -127,7 +127,7 @@ static BUILTIN_FUNCTIONS: [Prototype; 24] = [
         name: "blake2_128",
         args: &[Type::DynamicBytes],
         ret: &[Type::Bytes(16)],
-        target: &[Target::Substrate],
+        target: &[Target::Substrate { address_length: 0 }],
         doc: "Calculates blake2-128 hash",
         constant: true,
     },
@@ -137,7 +137,7 @@ static BUILTIN_FUNCTIONS: [Prototype; 24] = [
         name: "blake2_256",
         args: &[Type::DynamicBytes],
         ret: &[Type::Bytes(32)],
-        target: &[Target::Substrate],
+        target: &[Target::Substrate { address_length: 0 }],
         doc: "Calculates blake2-256 hash",
         constant: true,
     },
@@ -147,7 +147,7 @@ static BUILTIN_FUNCTIONS: [Prototype; 24] = [
         name: "gasleft",
         args: &[],
         ret: &[Type::Uint(64)],
-        target: &[Target::Substrate, Target::Ewasm],
+        target: &[Target::Substrate { address_length: 0 }, Target::Ewasm],
         doc: "Return remaing gas left in current call",
         constant: false,
     },
@@ -167,7 +167,7 @@ static BUILTIN_FUNCTIONS: [Prototype; 24] = [
         name: "random",
         args: &[Type::DynamicBytes],
         ret: &[Type::Bytes(32)],
-        target: &[Target::Substrate],
+        target: &[Target::Substrate { address_length: 0 }],
         doc: "Returns deterministic random bytes",
         constant: false,
     },
@@ -337,7 +337,7 @@ static BUILTIN_VARIABLE: [Prototype; 14] = [
         name: "tombstone_deposit",
         args: &[],
         ret: &[Type::Value],
-        target: &[Target::Substrate],
+        target: &[Target::Substrate { address_length: 0 }],
         doc: "Deposit required for a tombstone",
         constant: false,
     },
@@ -347,7 +347,7 @@ static BUILTIN_VARIABLE: [Prototype; 14] = [
         name: "minimum_balance",
         args: &[],
         ret: &[Type::Value],
-        target: &[Target::Substrate],
+        target: &[Target::Substrate { address_length: 0 }],
         doc: "Minimum balance required for an account",
         constant: false,
     },
@@ -397,7 +397,7 @@ static BUILTIN_VARIABLE: [Prototype; 14] = [
         name: "gasprice",
         args: &[],
         ret: &[Type::Value],
-        target: &[Target::Substrate, Target::Ewasm],
+        target: &[Target::Substrate { address_length: 0 }, Target::Ewasm],
         doc: "gas price for one gas unit",
         constant: false,
     },
@@ -444,7 +444,7 @@ pub fn builtin_var(
         .find(|p| p.name == fname && p.namespace == namespace)
     {
         if p.target.is_empty() || p.target.contains(&ns.target) {
-            if ns.target == Target::Substrate && p.builtin == Builtin::Gasprice {
+            if ns.target.is_substrate() && p.builtin == Builtin::Gasprice {
                 diagnostics.push(Diagnostic::error(
                     *loc,
                     String::from(
@@ -576,7 +576,7 @@ pub fn resolve_call(
             diagnostics.truncate(marker);
 
             // tx.gasprice(1) is a bad idea, just like tx.gasprice. Warn about this
-            if ns.target == Target::Substrate && func.builtin == Builtin::Gasprice {
+            if ns.target.is_substrate() && func.builtin == Builtin::Gasprice {
                 if let Ok((_, val)) = eval_const_number(&cast_args[0], contract_no, ns) {
                     if val == BigInt::one() {
                         diagnostics.push(Diagnostic::warning(

+ 2 - 2
src/sema/expression.rs

@@ -2451,7 +2451,7 @@ fn address_literal(
     ns: &mut Namespace,
     diagnostics: &mut Vec<Diagnostic>,
 ) -> Result<Expression, ()> {
-    if ns.target == Target::Substrate {
+    if ns.target.is_substrate() {
         match address.from_base58() {
             Ok(v) => {
                 if v.len() != 35 {
@@ -5142,7 +5142,7 @@ fn member_access(
         }
         Type::Address(_) => {
             if id.name == "balance" {
-                if ns.target == crate::Target::Substrate {
+                if ns.target.is_substrate() {
                     let mut is_this = false;
 
                     if let Expression::Cast(_, _, this) = &expr {

+ 1 - 1
src/sema/functions.rs

@@ -978,7 +978,7 @@ pub fn resolve_returns(
 fn signatures() {
     use super::*;
 
-    let mut ns = Namespace::new(Target::Ewasm, 20, 16);
+    let mut ns = Namespace::new(Target::Ewasm);
 
     ns.contracts.push(ast::Contract::new(
         "bar",

+ 13 - 1
src/sema/mod.rs

@@ -312,7 +312,19 @@ fn resolve_pragma(name: &pt::Identifier, value: &pt::StringLiteral, ns: &mut ast
 
 impl ast::Namespace {
     /// Create a namespace and populate with the parameters for the target
-    pub fn new(target: Target, address_length: usize, value_length: usize) -> Self {
+    pub fn new(target: Target) -> Self {
+        let address_length = match target {
+            Target::Ewasm => 20,
+            Target::Substrate { address_length } => address_length,
+            Target::Solana => 32,
+        };
+
+        let value_length = if target == Target::Solana {
+            8 // lamports is u64
+        } else {
+            16 // value is 128 bits
+        };
+
         ast::Namespace {
             target,
             files: Vec::new(),

+ 2 - 2
tests/substrate.rs

@@ -1194,7 +1194,7 @@ pub fn build_solidity(src: &'static str) -> TestRuntime {
         "test.sol",
         &mut cache,
         inkwell::OptimizationLevel::Default,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
         false,
     );
 
@@ -1231,7 +1231,7 @@ pub fn build_solidity_with_overflow_check(src: &'static str) -> TestRuntime {
         "test.sol",
         &mut cache,
         inkwell::OptimizationLevel::Default,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
         true,
     );
 

+ 34 - 34
tests/substrate_tests/arrays.rs

@@ -22,7 +22,7 @@ fn missing_array_index() {
                     return bar[];
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -39,7 +39,7 @@ fn missing_array_index() {
                     return bar[0];
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -226,7 +226,7 @@ fn data_locations() {
             function bar(uint storage) public returns () {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -240,7 +240,7 @@ fn data_locations() {
             function bar(uint calldata x) public returns () {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -255,7 +255,7 @@ fn data_locations() {
             function bar(foo2 memory x) public returns () {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -270,7 +270,7 @@ fn data_locations() {
             function bar(foo2 x) public returns (uint calldata) {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -285,7 +285,7 @@ fn data_locations() {
             function bar(foo2 x) public returns (bool calldata) {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -300,7 +300,7 @@ fn data_locations() {
             function bar(foo2 x) public returns (int storage) {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -315,7 +315,7 @@ fn data_locations() {
             function bar(int[10] storage x) public returns (int) {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -330,7 +330,7 @@ fn data_locations() {
             function bar() public returns (int[10] storage x) {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -345,7 +345,7 @@ fn data_locations() {
             function bar() public returns (foo2[10] storage x) {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -509,7 +509,7 @@ fn array_dimensions() {
         contract foo {
             bool[10 - 10] x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "zero size array not permitted");
@@ -519,7 +519,7 @@ fn array_dimensions() {
         contract foo {
             bool[-10 + 10] x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -532,7 +532,7 @@ fn array_dimensions() {
         contract foo {
             bool[1 / 10] x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "zero size array not permitted");
@@ -543,7 +543,7 @@ fn array_dimensions() {
             enum e { e1, e2, e3 }
             e[1 / 0] x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "divide by zero");
@@ -556,7 +556,7 @@ fn array_dimensions() {
             }
             bar[1 % 0] x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "divide by zero");
@@ -790,7 +790,7 @@ fn memory_dynamic_array_new() {
                 assert(a.length == 5);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -807,7 +807,7 @@ fn memory_dynamic_array_new() {
                 assert(a.length == 5);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -824,7 +824,7 @@ fn memory_dynamic_array_new() {
                 assert(a.length == 5);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -841,7 +841,7 @@ fn memory_dynamic_array_new() {
                 assert(a.length == 5);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -858,7 +858,7 @@ fn memory_dynamic_array_new() {
                 assert(a.length == 5);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -905,7 +905,7 @@ fn memory_dynamic_array_deref() {
                 a[-1] = 5;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -923,7 +923,7 @@ fn memory_dynamic_array_deref() {
                 a[i] = 5;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1098,7 +1098,7 @@ fn dynamic_array_push() {
                 bar.push(102, 20);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1228,7 +1228,7 @@ fn dynamic_array_pop() {
                 bar.pop(102);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1376,7 +1376,7 @@ fn storage_dynamic_array_push() {
                 bar.push(102, 20);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1393,7 +1393,7 @@ fn storage_dynamic_array_push() {
                 bar.push(102);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1459,7 +1459,7 @@ fn storage_dynamic_array_push() {
                 s storage n = bar.push(s(-1, false));
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1480,7 +1480,7 @@ fn storage_dynamic_array_pop() {
                 bar.pop(102);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1497,7 +1497,7 @@ fn storage_dynamic_array_pop() {
                 bar.pop();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1582,7 +1582,7 @@ fn storage_dynamic_array_pop() {
                 s storage x = bar.pop();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1602,7 +1602,7 @@ fn storage_delete() {
                 delete 102;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1619,7 +1619,7 @@ fn storage_delete() {
                 int32 x = delete bar;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -2015,7 +2015,7 @@ fn lucas() {
         }
     }
     "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);

+ 27 - 27
tests/substrate_tests/builtins.rs

@@ -13,7 +13,7 @@ fn abi_decode() {
                 (int a) = abi.decode(hex"00", feh);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "type ‘feh’ not found");
@@ -25,7 +25,7 @@ fn abi_decode() {
                 (int a) = abi.decode(hex"00", (int storage));
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -40,7 +40,7 @@ fn abi_decode() {
                 (int a) = abi.decode(hex"00", (int feh));
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -55,7 +55,7 @@ fn abi_decode() {
                 (int a) = abi.decode(hex"00", (int,));
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "missing type");
@@ -67,7 +67,7 @@ fn abi_decode() {
                 (int a) = abi.decode(hex"00", (int,mapping(uint[] => address)));
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -198,7 +198,7 @@ fn abi_encode_with_selector() {
                 bytes x = abi.encodeWithSelector();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -244,7 +244,7 @@ fn abi_encode_with_signature() {
                 bytes x = abi.encodeWithSignature();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -292,7 +292,7 @@ fn call() {
                 x.delegatecall(hex"1222");
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -309,7 +309,7 @@ fn call() {
                 x.staticcall(hex"1222");
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -332,7 +332,7 @@ fn call() {
                 print("Baa!");
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -355,7 +355,7 @@ fn call() {
                 print("Baa!");
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -496,7 +496,7 @@ fn block() {
                 assert(b == 14_250_083_331_950_119_597);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -526,7 +526,7 @@ fn block() {
                 assert(b == 14_250_083_331_950_119_597);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -556,7 +556,7 @@ fn block() {
                 assert(b == 93_603_701_976_053);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -586,7 +586,7 @@ fn block() {
                 assert(b == 93_603_701_976_053);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -603,7 +603,7 @@ fn block() {
                 assert(b == 93_603_701_976_053);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -620,7 +620,7 @@ fn block() {
                 assert(b == 93_603_701_976_053);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -637,7 +637,7 @@ fn block() {
                 assert(b == 93_603_701_976_053);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -681,7 +681,7 @@ fn tx() {
                 int128 b = tx.gasprice;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -696,7 +696,7 @@ fn tx() {
                 int128 b = tx.gasprice(4-3);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -713,7 +713,7 @@ fn tx() {
                 assert(b == 14_250_083_331_950_119_597);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -730,7 +730,7 @@ fn tx() {
                 assert(b == 93_603_701_976_053);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -764,7 +764,7 @@ fn msg() {
                 assert(b == 14_250_083_331_950_119_597);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -779,7 +779,7 @@ fn msg() {
                 return msg.value > v;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -830,7 +830,7 @@ fn functions() {
                 assert(b == 14_250_083_331_950_119_597);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -847,7 +847,7 @@ fn functions() {
                 assert(b == 14_250_083_331_950_119_597);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -862,7 +862,7 @@ fn functions() {
                 bytes32 b = blockhash(1);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 17 - 17
tests/substrate_tests/calls.rs

@@ -183,7 +183,7 @@ fn try_catch_external_calls() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -212,7 +212,7 @@ fn try_catch_external_calls() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -292,7 +292,7 @@ fn try_catch_external_calls() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -321,7 +321,7 @@ fn try_catch_external_calls() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "x is already declared");
@@ -349,7 +349,7 @@ fn try_catch_external_calls() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -380,7 +380,7 @@ fn try_catch_external_calls() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -524,7 +524,7 @@ fn try_catch_constructor() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -551,7 +551,7 @@ fn try_catch_constructor() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -655,7 +655,7 @@ fn try_catch_constructor() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -670,7 +670,7 @@ fn try_catch_constructor() {
                 x : 1
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -695,7 +695,7 @@ fn try_catch_constructor() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -724,7 +724,7 @@ fn try_catch_constructor() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "unexpected code block");
@@ -750,7 +750,7 @@ fn try_catch_constructor() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "unexpected code block");
@@ -966,7 +966,7 @@ fn payable_functions() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -982,7 +982,7 @@ fn payable_functions() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -998,7 +998,7 @@ fn payable_functions() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1014,7 +1014,7 @@ fn payable_functions() {
             }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 21 - 21
tests/substrate_tests/contracts.rs

@@ -13,7 +13,7 @@ fn contract_name() {
         "contract test {
             function test() public {}
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -25,7 +25,7 @@ fn contract_name() {
         "contract test {
             enum test { a}
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -37,7 +37,7 @@ fn contract_name() {
         "contract test {
             bool test;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -49,7 +49,7 @@ fn contract_name() {
         "contract test {
             struct test { bool a; }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -63,7 +63,7 @@ fn contract_name() {
                 int test;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -76,7 +76,7 @@ fn contract_name() {
             function f(int test) public {
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -90,7 +90,7 @@ fn contract_name() {
                 return 0;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -112,7 +112,7 @@ fn contract_name() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -140,7 +140,7 @@ fn contract_name() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -168,7 +168,7 @@ fn contract_type() {
                 printer y = printer(x);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -183,7 +183,7 @@ fn contract_type() {
                 printer x = printer(address(102));
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -201,7 +201,7 @@ fn contract_type() {
                 address y = 102;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -222,7 +222,7 @@ fn contract_type() {
                 printer y = 102;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -237,7 +237,7 @@ fn contract_type() {
                 return new printer();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -252,7 +252,7 @@ fn contract_type() {
                 return new printer({});
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -277,7 +277,7 @@ fn external_call() {
                 return 1;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -299,7 +299,7 @@ fn external_call() {
                 return 1;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -328,7 +328,7 @@ fn external_call() {
                 return x * t;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -357,7 +357,7 @@ fn external_call() {
                 return x * t;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "duplicate argument name ‘a’");
@@ -529,7 +529,7 @@ fn creation_code() {
                 }
         }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -544,7 +544,7 @@ fn creation_code() {
                     bytes code = type(a).runtimeCode;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 5 - 5
tests/substrate_tests/enums.rs

@@ -92,7 +92,7 @@ fn test_cast_errors() {
                 return state.foo;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -107,7 +107,7 @@ fn test_cast_errors() {
                 return state.foo;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "enum ‘state’ has no fields");
@@ -119,7 +119,7 @@ fn test_cast_errors() {
                 return uint8(state.foo);
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -127,7 +127,7 @@ fn test_cast_errors() {
 
 #[test]
 fn incorrect_fields() {
-    let ns = parse_and_resolve("enum state { }", Target::Substrate);
+    let ns = parse_and_resolve("enum state { }", Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "enum ‘state’ has no fields");
 
@@ -161,7 +161,7 @@ fn incorrect_fields() {
         foo243, foo244, foo245, foo246, foo247, foo248, foo249, foo250, foo251,
         foo252, foo253, foo254, foo255, foo256
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 43 - 27
tests/substrate_tests/events.rs

@@ -11,7 +11,7 @@ fn event_decl() {
         contract c {
             event foo ();
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -20,7 +20,7 @@ fn event_decl() {
         r#"
         enum e { a1 }
         event e();"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -34,7 +34,7 @@ fn event_decl() {
         contract c {
             event e();
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -48,7 +48,7 @@ fn event_decl() {
             enum e { a1 }
             event e();
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -61,7 +61,7 @@ fn event_decl() {
         contract c {
             event foo (mapping (bool => uint) x);
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -78,7 +78,7 @@ fn event_decl() {
         contract c {
             event foo (s x);
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -91,7 +91,7 @@ fn event_decl() {
         contract c {
             event foo (bool x, uint32 y, address x);
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -104,7 +104,7 @@ fn event_decl() {
         contract c {
             event foo (bool indexed f1, bool indexed f2, bool indexed f3, bool indexed f4);
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -117,7 +117,7 @@ fn event_decl() {
         contract c {
             event foo (bool indexed f1, bool indexed f2, bool indexed f3);
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -127,7 +127,7 @@ fn event_decl() {
         contract c {
             event foo (bool indexed f1, bool indexed f2, bool indexed f3, bool indexed f4, bool indexed f5) anonymous;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -140,7 +140,7 @@ fn event_decl() {
         contract c {
             event foo (bool indexed f1, bool indexed f2, bool indexed f3, bool indexed f4) anonymous;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -155,7 +155,7 @@ fn emit() {
                 emit 1 ();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -171,7 +171,7 @@ fn emit() {
                 emit foo {};
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -187,7 +187,7 @@ fn emit() {
                 emit foo (true);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -203,7 +203,7 @@ fn emit() {
                 emit foo (true, "ab");
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -219,7 +219,7 @@ fn emit() {
                 emit foo ({a:true, a:"ab"});
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -235,7 +235,7 @@ fn emit() {
                 emit foo ({a:true, b:"ab"});
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -251,7 +251,7 @@ fn emit() {
                 emit foo (true, 102);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -339,7 +339,11 @@ fn event_imported() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -369,7 +373,11 @@ fn event_imported() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -399,7 +407,11 @@ fn event_imported() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -427,7 +439,11 @@ fn event_imported() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 }
@@ -445,7 +461,7 @@ fn inherited() {
                 emit foo(true, 1);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -466,7 +482,7 @@ fn signatures() {
                 emit foo(true, 1);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -483,7 +499,7 @@ fn signatures() {
                 emit foo(true, 1);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -500,7 +516,7 @@ fn signatures() {
                 emit foo(true, 1);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -516,7 +532,7 @@ fn signatures() {
                 emit foo(true, 1);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);

+ 12 - 12
tests/substrate_tests/expressions.rs

@@ -251,7 +251,7 @@ fn test_cast_errors() {
                 bool is_nonzero = bar;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -265,7 +265,7 @@ fn test_cast_errors() {
                 return (foo < bar);
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -280,7 +280,7 @@ fn test_cast_errors() {
                 return false;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -293,7 +293,7 @@ fn test_cast_errors() {
                 return false;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -330,7 +330,7 @@ fn test_cast_errors() {
                 set_x(uint32(b));
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -968,7 +968,7 @@ fn power() {
                 return base ** exp;
             }
        }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -982,7 +982,7 @@ fn power() {
                 return base ** exp;
             }
        }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -996,7 +996,7 @@ fn power() {
                 return base ** exp;
             }
        }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1381,7 +1381,7 @@ fn destructure() {
                 (a, b) = (1, 2, 3);
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1398,7 +1398,7 @@ fn destructure() {
                 (c, b) = (1, 2);
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "`c\' is not found");
@@ -1412,7 +1412,7 @@ fn destructure() {
                 (a memory, b) = (1, 2);
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1429,7 +1429,7 @@ fn destructure() {
                 (a , b) = (1, );
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "stray comma");

+ 1 - 1
tests/substrate_tests/first.rs

@@ -7,7 +7,7 @@ use solang::Target;
 #[test]
 fn simple_solidiy_compile_and_run() {
     // try empty file
-    let ns = parse_and_resolve("", Target::Substrate);
+    let ns = parse_and_resolve("", Target::Substrate { address_length: 32 });
 
     no_errors(ns.diagnostics);
 

+ 9 - 9
tests/substrate_tests/format.rs

@@ -13,7 +13,7 @@ fn parse() {
                 s.format();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -28,7 +28,7 @@ fn parse() {
                 string s = "foo{".format();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "missing closing ‘}’");
@@ -40,7 +40,7 @@ fn parse() {
                 string s = "foo{d".format();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "unexpected format char ‘d’");
@@ -52,7 +52,7 @@ fn parse() {
                 string s = "foo{:".format();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "missing format specifier");
@@ -64,7 +64,7 @@ fn parse() {
                 string s = "foo{:}s".format();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "missing argument to format");
@@ -76,7 +76,7 @@ fn parse() {
                 string s = "f{{oo}s".format();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "unmatched ‘}’");
@@ -88,7 +88,7 @@ fn parse() {
                 string s = "f{{oo}}s".format(true);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -103,7 +103,7 @@ fn parse() {
                 string s = "{}" "{:x}s".format(1, true);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -118,7 +118,7 @@ fn parse() {
                 string s = "{}" "{:x}s".format(1, 0xcafe);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);

+ 18 - 18
tests/substrate_tests/function_types.rs

@@ -11,7 +11,7 @@ fn decls() {
                 function() public a;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -25,7 +25,7 @@ fn decls() {
                 function() private a;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -39,7 +39,7 @@ fn decls() {
                 function() returns (bool) internal a;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -53,7 +53,7 @@ fn decls() {
                 function() returns (bool) pure a;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -67,7 +67,7 @@ fn decls() {
                 function() returns (bool x) a;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -81,7 +81,7 @@ fn decls() {
                 function(address tre) returns (bool) a;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -95,7 +95,7 @@ fn decls() {
             function foo(function(address) pure internal returns (bool) a) public {
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -108,7 +108,7 @@ fn decls() {
             function foo() public returns (function(address) pure internal returns (bool) a) {
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -120,7 +120,7 @@ fn decls() {
         "contract test {
             function(address) pure internal returns (bool) public a;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -139,7 +139,7 @@ fn assign() {
                 function(int32) pure a = x;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -155,7 +155,7 @@ fn assign() {
                 function(int32) view a = x;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -171,7 +171,7 @@ fn assign() {
                 function(int32) a = x;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -189,7 +189,7 @@ fn assign() {
                 function(int32) a = x;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -207,7 +207,7 @@ fn assign() {
                 function(int32) returns (bool) a = x;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -425,7 +425,7 @@ fn ext() {
                 return false;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -444,7 +444,7 @@ fn ext() {
                 return false;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -467,7 +467,7 @@ fn ext() {
                 return false;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -625,7 +625,7 @@ fn variable_or_func_type() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);

+ 56 - 50
tests/substrate_tests/functions.rs

@@ -13,7 +13,7 @@ fn constructors() {
         contract test {
             constructor() internal {}
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -26,7 +26,7 @@ fn constructors() {
         contract test {
             constructor() virtual {}
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -128,7 +128,7 @@ fn fallback() {
                 result = 356;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -250,7 +250,7 @@ fn mutability() {
                 return foo;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -264,7 +264,7 @@ fn mutability() {
                 return 102;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -278,7 +278,7 @@ fn mutability() {
                 return foo[0];
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -294,7 +294,7 @@ fn mutability() {
                 foo = 102;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -308,7 +308,7 @@ fn mutability() {
                 foo[0] = 102;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -322,7 +322,7 @@ fn mutability() {
                 (bool f, bytes memory res) = a.call(hex"0102");
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -336,7 +336,7 @@ fn mutability() {
                 (f, res) = a.call(hex"0102");
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(ns.diagnostics.len(), 1);
@@ -348,7 +348,7 @@ fn mutability() {
                 return true;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_warnings(&ns.diagnostics);
@@ -361,7 +361,7 @@ fn mutability() {
                 return foo;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_warnings_errors(ns.diagnostics);
@@ -372,7 +372,7 @@ fn mutability() {
                 return 102;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_warnings_errors(ns.diagnostics);
@@ -383,7 +383,7 @@ fn mutability() {
                 return 102;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -395,7 +395,7 @@ fn mutability() {
         "contract test {
             int64 constant public foo = 1844674;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_warnings_errors(ns.diagnostics);
@@ -423,7 +423,7 @@ fn shadowing() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_warning(ns.diagnostics),
@@ -463,7 +463,7 @@ fn scopes() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "`a\' is not found");
 
@@ -477,7 +477,7 @@ fn scopes() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "`i\' is not found");
 }
@@ -494,7 +494,7 @@ fn for_forever() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "unreachable statement");
 }
@@ -620,7 +620,7 @@ fn args_and_returns() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "arg1 is already declared");
 
@@ -630,7 +630,7 @@ fn args_and_returns() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "arg2 is already declared");
 
@@ -640,7 +640,7 @@ fn args_and_returns() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "missing return statement");
 
@@ -663,7 +663,7 @@ fn args_and_returns() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "missing return statement");
 
@@ -702,7 +702,7 @@ fn named_argument_call() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -719,7 +719,7 @@ fn named_argument_call() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "unexpected array type");
 
@@ -733,7 +733,7 @@ fn named_argument_call() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -750,7 +750,7 @@ fn named_argument_call() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -767,7 +767,7 @@ fn named_argument_call() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -811,7 +811,7 @@ fn positional_argument_call() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -828,7 +828,7 @@ fn positional_argument_call() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(first_error(ns.diagnostics), "expression is not an array");
 
@@ -842,7 +842,7 @@ fn positional_argument_call() {
         }
     }";
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -958,7 +958,7 @@ fn payable() {
             }
         }"##;
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -976,7 +976,7 @@ fn payable() {
             }
         }"##;
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -994,7 +994,7 @@ fn payable() {
             }
         }"##;
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -1012,7 +1012,7 @@ fn payable() {
             }
         }"##;
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -1027,7 +1027,7 @@ fn payable() {
             }
         }"##;
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -1042,7 +1042,7 @@ fn payable() {
             }
         }"##;
 
-    let ns = parse_and_resolve(src, Target::Substrate);
+    let ns = parse_and_resolve(src, Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -1056,7 +1056,7 @@ fn global_functions() {
         r##"
         function() {}
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "missing function name");
@@ -1065,7 +1065,7 @@ fn global_functions() {
         r##"
         function x();
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "missing function body");
@@ -1074,7 +1074,7 @@ fn global_functions() {
         r##"
         function x() virtual {}
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1086,7 +1086,7 @@ fn global_functions() {
         r##"
         function x() override {}
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1098,7 +1098,7 @@ fn global_functions() {
         r##"
         function x() feyla {}
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1110,7 +1110,7 @@ fn global_functions() {
         r##"
         function x() feyla {}
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1124,7 +1124,7 @@ fn global_functions() {
 
         function x() pure { emit foo(true); }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1136,7 +1136,7 @@ fn global_functions() {
         r##"
         function x(int[] storage x) pure returns (int) { return x[1]; }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1153,7 +1153,7 @@ fn global_functions() {
 
         function x(S storage x) view { x.f1 = 102; }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1167,7 +1167,7 @@ fn global_functions() {
         function x(int128) pure { return 102; }
         function x(int128) pure { return 132; }
         "##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1245,7 +1245,7 @@ fn return_not_returns() {
                 return 1;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1256,11 +1256,17 @@ fn return_not_returns() {
 
 #[test]
 fn stray_semicolon() {
-    let ns = parse_and_resolve("struct a { uint32 f1; };", Target::Substrate);
+    let ns = parse_and_resolve(
+        "struct a { uint32 f1; };",
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(first_error(ns.diagnostics), "stray semicolon");
 
-    let ns = parse_and_resolve("contract x { struct a { uint32 f1; }; }", Target::Substrate);
+    let ns = parse_and_resolve(
+        "contract x { struct a { uint32 f1; }; }",
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(first_error(ns.diagnostics), "stray semicolon");
 }

+ 100 - 20
tests/substrate_tests/imports.rs

@@ -26,7 +26,11 @@ fn enum_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -52,7 +56,11 @@ fn enum_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -78,7 +86,11 @@ fn enum_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -100,7 +112,11 @@ fn enum_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -118,7 +134,11 @@ fn enum_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -135,7 +155,11 @@ fn enum_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -167,7 +191,11 @@ fn struct_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -193,7 +221,11 @@ fn struct_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(first_error(ns.diagnostics), "type ‘struct_a’ not found");
 }
@@ -230,7 +262,11 @@ fn contract_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -273,7 +309,11 @@ fn contract_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -316,7 +356,11 @@ fn contract_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 }
@@ -339,7 +383,11 @@ fn circular_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("self.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "self.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -380,7 +428,11 @@ fn circular_import() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 }
@@ -414,7 +466,11 @@ fn import_symbol() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -449,7 +505,11 @@ fn import_symbol() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -484,7 +544,11 @@ fn import_symbol() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -529,7 +593,11 @@ fn import_symbol() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 }
@@ -579,7 +647,11 @@ fn enum_import_chain() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 
@@ -626,7 +698,11 @@ fn enum_import_chain() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -675,7 +751,11 @@ fn import_base_dir() {
         .to_string(),
     );
 
-    let ns = solang::parse_and_resolve("a.sol", &mut cache, Target::Substrate);
+    let ns = solang::parse_and_resolve(
+        "a.sol",
+        &mut cache,
+        Target::Substrate { address_length: 32 },
+    );
 
     no_errors(ns.diagnostics);
 }

+ 79 - 76
tests/substrate_tests/inheritance.rs

@@ -11,7 +11,7 @@ fn test_virtual() {
         contract c {
             function test() public;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -24,7 +24,7 @@ fn test_virtual() {
         contract c {
             function test() virtual public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -35,7 +35,7 @@ fn test_virtual() {
             function test() virtual public;
             function test2() virtual public;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -62,7 +62,7 @@ fn test_abstract() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -86,7 +86,7 @@ fn test_abstract() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -120,7 +120,7 @@ fn test_abstract() {
         "a.sol",
         &mut cache,
         inkwell::OptimizationLevel::Default,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
         false,
     );
 
@@ -158,7 +158,7 @@ fn test_abstract() {
         "a.sol",
         &mut cache,
         inkwell::OptimizationLevel::Default,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
         false,
     );
 
@@ -176,7 +176,7 @@ fn test_interface() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -190,7 +190,7 @@ fn test_interface() {
             function bar() external {}
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -204,7 +204,7 @@ fn test_interface() {
             function bar() private;
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -218,7 +218,7 @@ fn test_interface() {
             function bar() internal;
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -236,7 +236,7 @@ fn test_interface() {
             function f() internal {}
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -254,7 +254,7 @@ fn test_interface() {
             function f() internal {}
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -268,7 +268,7 @@ fn test_interface() {
             function foo() virtual external;
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -282,7 +282,7 @@ fn test_interface() {
             int x;
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -296,7 +296,7 @@ fn test_interface() {
             int constant x = 1;
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -325,7 +325,7 @@ fn test_interface() {
             function f2(address a) public {}
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -340,7 +340,7 @@ fn inherit() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -355,7 +355,7 @@ fn inherit() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "contract ‘foo’ not found");
@@ -372,7 +372,7 @@ fn inherit() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -392,7 +392,7 @@ fn inherit() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -417,7 +417,7 @@ fn inherit() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -447,7 +447,7 @@ fn inherit() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -470,7 +470,7 @@ fn inherit_types() {
             enum enum_x { x1, x2 }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -495,7 +495,7 @@ fn inherit_types() {
             enum enum_x { x1, x2 }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -520,7 +520,7 @@ fn inherit_types() {
             enum enum_x { x1, x2 }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -537,7 +537,7 @@ fn inherit_types() {
             enum enum_x { x1, x2 }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "type ‘enum_x’ not found");
@@ -555,7 +555,7 @@ fn inherit_types() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -578,7 +578,7 @@ fn inherit_types() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "already defined ‘foo’");
@@ -598,7 +598,7 @@ fn inherit_variables() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -615,7 +615,7 @@ fn inherit_variables() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "`foo\' is not found");
@@ -636,7 +636,7 @@ fn inherit_variables() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -657,7 +657,7 @@ fn inherit_variables() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -674,7 +674,7 @@ fn inherit_variables() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -779,7 +779,7 @@ fn call_inherited_function() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "cannot call private function");
@@ -798,7 +798,7 @@ fn call_inherited_function() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "cannot call private function");
@@ -821,7 +821,7 @@ fn call_inherited_function() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -927,7 +927,7 @@ fn test_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -943,7 +943,7 @@ fn test_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -963,7 +963,7 @@ fn test_override() {
             function f() private {}
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -979,7 +979,7 @@ fn test_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1001,7 +1001,7 @@ fn test_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1027,7 +1027,7 @@ fn test_override() {
             uint64 public x;
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1047,7 +1047,7 @@ fn test_override() {
                 x = 2;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1075,7 +1075,7 @@ fn test_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -1163,7 +1163,7 @@ fn test_override() {
                 function bar(int x) public { print ("foo"); }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1181,7 +1181,7 @@ fn test_override() {
                 function bar(int64 x) public override;
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1212,7 +1212,7 @@ fn multiple_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1240,7 +1240,7 @@ fn multiple_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1274,7 +1274,7 @@ fn multiple_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1302,7 +1302,7 @@ fn multiple_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1330,7 +1330,7 @@ fn multiple_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1362,7 +1362,7 @@ fn multiple_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1394,7 +1394,7 @@ fn multiple_override() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1420,7 +1420,7 @@ fn base_contract() {
                 return a + 102;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1439,7 +1439,7 @@ fn base_contract() {
                 return a + 102;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1493,7 +1493,7 @@ fn base_contract_on_constructor() {
 
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1516,7 +1516,7 @@ fn base_contract_on_constructor() {
 
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1531,7 +1531,7 @@ fn base_contract_on_constructor() {
 
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1546,7 +1546,7 @@ fn base_contract_on_constructor() {
 
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1563,7 +1563,7 @@ fn base_contract_on_constructor() {
         contract apex is base {
                 function foo() pure public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1581,7 +1581,7 @@ fn base_contract_on_constructor() {
             constructor() base(true) base(false) {}
             function foo() pure public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1707,7 +1707,7 @@ fn base_contract_on_constructor() {
             function get_foo() public returns (int64) { return foo; }
             constructor(int64 z) { foo = z; }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1730,7 +1730,7 @@ fn base_contract_on_constructor() {
             function get_foo() public returns (int64) { return foo; }
             constructor(int64 z) { foo = z; }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "duplicate base contract ‘b’");
@@ -1750,7 +1750,7 @@ fn base_contract_on_constructor() {
             function get_foo() public returns (int64) { return foo; }
             constructor(int64 z) { foo = z; }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1835,7 +1835,7 @@ fn simple_interface() {
                 return a * 2;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -1903,7 +1903,7 @@ fn cast_contract() {
                 return a / b;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -1919,7 +1919,7 @@ fn cast_contract() {
                 foo y = x;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1930,7 +1930,10 @@ fn cast_contract() {
 
 #[test]
 fn test_super() {
-    let ns = parse_and_resolve(r#"contract super {}"#, Target::Substrate);
+    let ns = parse_and_resolve(
+        r#"contract super {}"#,
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -1941,7 +1944,7 @@ fn test_super() {
         r#"
         function f1() { super.a(); }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -1960,7 +1963,7 @@ fn test_super() {
                 super.f2();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "unknown function or type ‘f2’");
@@ -2068,7 +2071,7 @@ fn mutability() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -2088,7 +2091,7 @@ fn mutability() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -2113,7 +2116,7 @@ fn visibility() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -2130,7 +2133,7 @@ fn visibility() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -2150,7 +2153,7 @@ fn visibility() {
             }
         }
         "#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 16 - 16
tests/substrate_tests/libraries.rs

@@ -10,7 +10,7 @@ fn restrictions() {
         library c {
             constructor() {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -23,7 +23,7 @@ fn restrictions() {
         library c {
             receive() internal {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -36,7 +36,7 @@ fn restrictions() {
         library c {
             fallback() internal {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -49,7 +49,7 @@ fn restrictions() {
         library c {
             function f() public payable {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -62,7 +62,7 @@ fn restrictions() {
         library c {
             function foo() virtual public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -75,7 +75,7 @@ fn restrictions() {
         library c {
             function foo() override public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -88,7 +88,7 @@ fn restrictions() {
         library c is x {
             fallback() internal {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -105,7 +105,7 @@ fn restrictions() {
         contract a is c {
             function bar() public { }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -118,7 +118,7 @@ fn restrictions() {
         library c {
             int x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -174,7 +174,7 @@ fn using() {
         contract c {
             using x for x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "library ‘x’ not found");
@@ -188,7 +188,7 @@ fn using() {
         contract c {
             using x for x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -207,7 +207,7 @@ fn using() {
         contract c {
             using x for asdf;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "type ‘asdf’ not found");
@@ -223,7 +223,7 @@ fn using() {
         contract c {
             using x for x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -320,7 +320,7 @@ fn using() {
                 return a > b ? a : b;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "method ‘max’ does not exist");
@@ -340,7 +340,7 @@ fn using() {
                 return a > b ? a : b;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -368,7 +368,7 @@ fn using() {
                 return a;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 1 - 1
tests/substrate_tests/loops.rs

@@ -15,7 +15,7 @@ fn test_infinite_loop() {
                 return 0;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "unreachable statement");

+ 10 - 10
tests/substrate_tests/mappings.rs

@@ -22,7 +22,7 @@ fn bad_mapping_declares() {
                 x.data[1] = address(1);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -35,7 +35,7 @@ fn bad_mapping_declares() {
         contract c {
             mapping(uint[] => address) data;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -51,7 +51,7 @@ fn bad_mapping_declares() {
             }
             mapping(foo => address) data;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -65,7 +65,7 @@ fn bad_mapping_declares() {
             mapping(int => address) data;
             mapping(data => address) data2;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "‘data’ is a contract variable");
@@ -77,7 +77,7 @@ fn bad_mapping_declares() {
                 //
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -92,7 +92,7 @@ fn bad_mapping_declares() {
                 //
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -107,7 +107,7 @@ fn bad_mapping_declares() {
                 //
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -122,7 +122,7 @@ fn bad_mapping_declares() {
                 //
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -138,7 +138,7 @@ fn bad_mapping_declares() {
                 //
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -154,7 +154,7 @@ fn bad_mapping_declares() {
                 delete data;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 17 - 17
tests/substrate_tests/modifier.rs

@@ -10,7 +10,7 @@ fn declare() {
         contract c {
             modifier foo() public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -23,7 +23,7 @@ fn declare() {
         contract c {
             modifier foo() internal {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -36,7 +36,7 @@ fn declare() {
         contract c {
             modifier foo() payable {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -49,7 +49,7 @@ fn declare() {
         contract c {
             modifier foo() pure {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -62,7 +62,7 @@ fn declare() {
         contract c {
             modifier foo bar {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -75,7 +75,7 @@ fn declare() {
         contract c {
             modifier foo() {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "missing ‘_’ in modifier");
@@ -91,7 +91,7 @@ fn declare() {
                 }
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -107,7 +107,7 @@ fn declare() {
                 foo();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -122,7 +122,7 @@ fn declare() {
                 _;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -140,7 +140,7 @@ fn function_modifier() {
 
             function bar() foo2 public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "unknown modifier ‘foo2’");
@@ -152,7 +152,7 @@ fn function_modifier() {
 
             function bar() foo(1) public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -167,7 +167,7 @@ fn function_modifier() {
 
             function bar(bool x) foo(x) public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -183,10 +183,10 @@ fn chain() {
         contract c {
             uint16 public var;
 
-            modifier foo() { 
+            modifier foo() {
                 bool boom = true;
                 if (boom) {
-                    _; 
+                    _;
                 }
             }
 
@@ -508,7 +508,7 @@ fn mutability() {
 
             function bar() foo(var) public pure {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -524,7 +524,7 @@ fn mutability() {
 
             function bar() foo() public pure {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -543,7 +543,7 @@ fn mutability() {
         contract apex is base {
             function foo() public override {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 34 - 34
tests/substrate_tests/primitives.rs

@@ -91,7 +91,7 @@ fn test_literal_overflow() {
         "contract test {
             uint8 foo = 300;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -103,7 +103,7 @@ fn test_literal_overflow() {
         "contract test {
             uint16 foo = 0x10000;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -115,7 +115,7 @@ fn test_literal_overflow() {
         "contract test {
             int8 foo = 0x8_0;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -127,7 +127,7 @@ fn test_literal_overflow() {
         "contract test {
             int8 foo = -129;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -139,7 +139,7 @@ fn test_literal_overflow() {
         "contract test {
             int8 foo = 127;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -148,7 +148,7 @@ fn test_literal_overflow() {
         "contract test {
             int8 foo = -128;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -157,7 +157,7 @@ fn test_literal_overflow() {
         "contract test {
             uint8 foo = 255;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -166,7 +166,7 @@ fn test_literal_overflow() {
         "contract test {
             uint8 foo = -1_30;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -178,7 +178,7 @@ fn test_literal_overflow() {
         "contract test {
             int64 foo = 1844674_4073709551616;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -190,7 +190,7 @@ fn test_literal_overflow() {
         "contract test {
             bytes4 foo = 0xf12233;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -202,7 +202,7 @@ fn test_literal_overflow() {
         "contract test {
             bytes4 foo = 0x0122334455;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -214,7 +214,7 @@ fn test_literal_overflow() {
         "contract test {
             bytes4 foo = 0x00223344;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -311,7 +311,7 @@ fn address() {
         "contract test {
             address  foo = 0x1844674_4073709551616;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -323,7 +323,7 @@ fn address() {
         "contract test {
             address foo = 0xa368df6dfcd5ba7b0bc108af09e98e4655e35a2c3b2e2d5e3eae6c6f7cd8d2d4;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -335,7 +335,7 @@ fn address() {
         r#"contract test {
             address foo = address"5GBWmgdFAMqm8ZgAHGobqDqX6tjLxJhv53ygjNtaaAn3sje";
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -347,7 +347,7 @@ fn address() {
         r#"contract test {
             address foo = address"5GBWmgdFAMqm8ZgAHGobqDqX6tjLxJhv53ygjNtaaAn3sj%Z";
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -359,7 +359,7 @@ fn address() {
         r#"contract test {
             address foo = address"5GBWmgdFAMqm8ZgAHGobqDqX6tjLxJhv53ygjNtaaAn3sjZZ";
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -371,7 +371,7 @@ fn address() {
         r#"contract test {
             address foo = address"5GBWmgdFAMqm8ZgAHGobqDqX6tjLxJhv53ygjNtaaAn3sjeZ";
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -384,7 +384,7 @@ fn address() {
                 return foo > address(0);
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -397,7 +397,7 @@ fn address() {
                 return foo + address(1);
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -413,7 +413,7 @@ fn address() {
                 return foo | address(1);
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -425,7 +425,7 @@ fn address() {
         "contract test {
             address foo = 0x5b0Ddf2835f0A76c96D6113D47F6482e51a55487;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -482,7 +482,7 @@ fn address_payable_type() {
                 address b = a;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -499,7 +499,7 @@ fn address_payable_type() {
                 return b == a;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -516,7 +516,7 @@ fn address_payable_type() {
             function test() public {
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -536,7 +536,7 @@ fn address_payable_type() {
             function test() public {
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -556,7 +556,7 @@ fn address_payable_type() {
             function test() public {
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -568,7 +568,7 @@ fn address_payable_type() {
                 address b = address(a);
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -580,7 +580,7 @@ fn address_payable_type() {
                 address b = a;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -596,7 +596,7 @@ fn address_payable_type() {
                 address payable b = address payable(a);
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -665,7 +665,7 @@ fn type_name() {
                 int32 x = type(bool).max;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -714,7 +714,7 @@ fn units() {
                 int32 x = 1 ether;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -729,7 +729,7 @@ fn units() {
                 int32 x = 0xa days;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -744,7 +744,7 @@ fn units() {
                 int32 x = (1 + 2) days;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 11 - 11
tests/substrate_tests/strings.rs

@@ -16,7 +16,7 @@ fn basic_tests() {
                     f[0] = 102;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -31,7 +31,7 @@ fn basic_tests() {
                     bytes f = new string(2);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -46,7 +46,7 @@ fn basic_tests() {
                     string f = new bytes(2);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -61,7 +61,7 @@ fn basic_tests() {
                     string f = string(new bytes(2));
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -73,7 +73,7 @@ fn basic_tests() {
                     bytes f = bytes(new string(2));
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -678,7 +678,7 @@ fn string_escape() {
                     string f = "\x";
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -693,7 +693,7 @@ fn string_escape() {
                     string f = "\x9k";
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -708,7 +708,7 @@ fn string_escape() {
                     string f = "\xたこ";
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -723,7 +723,7 @@ fn string_escape() {
                     string f = "\u";
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -738,7 +738,7 @@ fn string_escape() {
                     string f = "\uたこ焼き";
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -753,7 +753,7 @@ fn string_escape() {
                     string f = "\u9kff";
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 13 - 13
tests/substrate_tests/structs.rs

@@ -21,7 +21,7 @@ fn parse_structs() {
                 uint a;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -37,7 +37,7 @@ fn parse_structs() {
                 uint storage b;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -53,7 +53,7 @@ fn parse_structs() {
                 uint calldata b;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -69,7 +69,7 @@ fn parse_structs() {
                 uint calldata b;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -83,7 +83,7 @@ fn parse_structs() {
             struct Foo {
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -98,7 +98,7 @@ fn parse_structs() {
                 boolean x;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "type ‘boolean’ not found");
@@ -112,7 +112,7 @@ fn parse_structs() {
                 Foo y;
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -137,7 +137,7 @@ fn parse_structs() {
             bytes4 selector;
             s foo;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "struct ‘s2’ has infinite size");
@@ -155,7 +155,7 @@ fn parse_structs() {
                 Foo a = Foo();
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -176,7 +176,7 @@ fn parse_structs() {
                 Foo a = Foo(true, true, true);
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -197,7 +197,7 @@ fn parse_structs() {
                 Foo a = Foo({ });
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -218,7 +218,7 @@ fn parse_structs() {
                 Foo a = Foo({ x: true, y: 1, z: 2 });
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -239,7 +239,7 @@ fn parse_structs() {
                 Foo a = Foo({ x: true, z: 1 });
             }
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "struct ‘Foo’ has no field ‘z’");

+ 27 - 27
tests/substrate_tests/tags.rs

@@ -7,7 +7,7 @@ fn contract() {
         r#"
         /// @barf
         contract test {}"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -25,7 +25,7 @@ fn contract() {
         /// @dev this is
         ///  a contract
         contract test {}"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(ns.contracts[0].tags[0].tag, "notice");
@@ -51,7 +51,7 @@ fn contract() {
          * a contract
          */
         contract test {}"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(ns.contracts[0].tags[0].tag, "notice");
@@ -66,7 +66,7 @@ fn contract() {
     assert_eq!(ns.contracts[0].tags[3].tag, "dev");
     assert_eq!(ns.contracts[0].tags[3].value, "this is a contract");
 
-    let ns = parse_and_resolve("/**\n", Target::Substrate);
+    let ns = parse_and_resolve("/**\n", Target::Substrate { address_length: 32 });
 
     assert_eq!(ns.diagnostics[0].pos, Some(Loc(0, 0, 4)));
     assert_eq!(ns.diagnostics[0].message, "end of file found in comment");
@@ -80,7 +80,7 @@ fn struct_tag() {
         struct x {
             uint32 f;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -94,7 +94,7 @@ fn struct_tag() {
         struct x {
             uint32 f;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "tag ‘@param’ no field ‘g’");
@@ -106,7 +106,7 @@ fn struct_tag() {
         struct x {
             uint32 f;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -122,7 +122,7 @@ fn struct_tag() {
             uint32 f1;
             uint32 f2;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(ns.diagnostics.len(), 0);
@@ -144,7 +144,7 @@ fn event_tag() {
         event x (
             uint32 f
         );"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -158,7 +158,7 @@ fn event_tag() {
         event x (
             uint32 f
         );"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "tag ‘@param’ no field ‘g’");
@@ -170,7 +170,7 @@ fn event_tag() {
         event x (
             uint32 f
         );"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -186,7 +186,7 @@ fn event_tag() {
             uint32 f1,
             uint32 f2
         );"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     //Event never emitted generates a warning
@@ -211,7 +211,7 @@ fn event_tag() {
                 uint32 f2
             );
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     //Event never emitted generates a warning
@@ -238,7 +238,7 @@ fn enum_tag() {
         enum x {
             foo1
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -252,7 +252,7 @@ fn enum_tag() {
          *  @dev bla bla bla
          * @author f2 bar */
         enum x { x1 }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(ns.diagnostics.len(), 0);
@@ -274,7 +274,7 @@ fn functions() {
             /// @param
             function foo() public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -289,7 +289,7 @@ fn functions() {
             /// @param g
             function foo(int f) public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "tag ‘@param’ no field ‘g’");
@@ -303,7 +303,7 @@ fn functions() {
              */
             function foo(int f) public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -317,7 +317,7 @@ fn functions() {
             /// @return so here we are
             function foo() public {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -331,7 +331,7 @@ fn functions() {
             /// @return so here we are
             function foo() public returns (int a, bool) {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "tag ‘@return’ no field ‘so’");
@@ -342,7 +342,7 @@ fn functions() {
             /// @return
             function foo() public returns (int a, bool b) {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -357,7 +357,7 @@ fn functions() {
             /// @return a barf
             function foo() public returns (int a, bool b) {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -371,7 +371,7 @@ fn functions() {
             /// @inheritdoc
             function foo() public returns (int a, bool b) {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -385,7 +385,7 @@ fn functions() {
             /// @inheritdoc b
             function foo() public returns (int a, bool b) {}
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -403,7 +403,7 @@ fn functions() {
         }
 
         contract b {}"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(ns.diagnostics.len(), 5);
@@ -427,7 +427,7 @@ fn variables() {
             /// @param
             int x;
         }"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -445,7 +445,7 @@ fn variables() {
         }
 
         contract b {}"#,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     //Variable 'y' has never been used (one item error in diagnostic)

+ 20 - 20
tests/substrate_tests/value.rs

@@ -21,7 +21,7 @@ fn external_call_value() {
                 a f = new a();
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -44,7 +44,7 @@ fn external_call_value() {
                 a f = new a();
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -67,7 +67,7 @@ fn external_call_value() {
                 a f = new a();
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -90,7 +90,7 @@ fn external_call_value() {
                 a f = new a();
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -113,7 +113,7 @@ fn external_call_value() {
                 a f = new a();
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -136,7 +136,7 @@ fn external_call_value() {
                 a f = new a();
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -159,7 +159,7 @@ fn external_call_value() {
                 a f = new a();
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "missing call arguments");
@@ -179,7 +179,7 @@ fn external_call_value() {
                 f.test{value: 1023}(501);
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -202,7 +202,7 @@ fn external_call_value() {
                 f.test{value: 1023}({l: 501});
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -226,7 +226,7 @@ fn external_call_value() {
                 f.test{value: x}({l: 501});
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -249,7 +249,7 @@ fn external_call_value() {
                 f.test{value: 2-2}({l: 501});
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -269,7 +269,7 @@ fn external_call_value() {
                 f.test{value: 0*10}(501);
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -549,7 +549,7 @@ fn this_address() {
                 return payable(this);
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -561,7 +561,7 @@ fn this_address() {
                 return this;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -576,7 +576,7 @@ fn this_address() {
                 this = other;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "expression is not assignable");
@@ -665,7 +665,7 @@ fn this_address() {
                 s = n;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -687,7 +687,7 @@ fn this_address() {
                 s = n;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -705,7 +705,7 @@ fn balance() {
                 return j.balance;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -720,7 +720,7 @@ fn balance() {
                 return j.balance;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -735,7 +735,7 @@ fn balance() {
                 return j.balance;
             }
         }"##,
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(

+ 32 - 26
tests/substrate_tests/variables.rs

@@ -8,7 +8,7 @@ fn variable_size() {
             function foo(int[12131231313213] memory y) public {}
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -21,7 +21,7 @@ fn variable_size() {
             function foo() public returns (int[12131231313213] memory y) {}
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -36,7 +36,7 @@ fn variable_size() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -56,7 +56,7 @@ fn immutable() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -73,7 +73,7 @@ fn immutable() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -90,7 +90,7 @@ fn immutable() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -107,7 +107,7 @@ fn immutable() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -126,7 +126,7 @@ fn immutable() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -139,7 +139,7 @@ fn immutable() {
             int immutable public immutable y = 1;
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -155,7 +155,7 @@ fn override_attribute() {
             int override y = 1;
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -168,7 +168,7 @@ fn override_attribute() {
             int override internal y = 1;
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -181,7 +181,7 @@ fn override_attribute() {
             int override private y = 1;
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -194,7 +194,7 @@ fn override_attribute() {
             int override override y = 1;
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -213,7 +213,7 @@ fn override_attribute() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -232,7 +232,7 @@ fn override_attribute() {
             }
         }
         ",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     no_errors(ns.diagnostics);
@@ -250,7 +250,7 @@ fn test_variable_errors() {
                 return a * b;
             }
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "`b' is not found");
@@ -264,7 +264,7 @@ fn test_variable_initializer_errors() {
             uint x = 102;
             uint constant y = x + 5;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -280,7 +280,7 @@ fn test_variable_initializer_errors() {
             }
             uint constant y = foo() + 5;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(
@@ -294,7 +294,7 @@ fn test_variable_initializer_errors() {
             uint x = y + 102;
             uint y = 102;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "`y' is not found");
@@ -305,7 +305,7 @@ fn test_variable_initializer_errors() {
             uint x = y + 102;
             uint constant y = 102;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "`y' is not found");
@@ -315,7 +315,7 @@ fn test_variable_initializer_errors() {
         "contract test {
             uint x = x + 102;
         }",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(first_error(ns.diagnostics), "`x' is not found");
@@ -323,28 +323,34 @@ fn test_variable_initializer_errors() {
 
 #[test]
 fn global_constants() {
-    let ns = parse_and_resolve("uint x = 102;", Target::Substrate);
+    let ns = parse_and_resolve("uint x = 102;", Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
         "global variable must be constant"
     );
 
-    let ns = parse_and_resolve("uint constant public x = 102;", Target::Substrate);
+    let ns = parse_and_resolve(
+        "uint constant public x = 102;",
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(
         first_error(ns.diagnostics),
         "‘public’: global variable cannot have visibility specifier"
     );
 
-    let ns = parse_and_resolve("uint constant external x = 102;", Target::Substrate);
+    let ns = parse_and_resolve(
+        "uint constant external x = 102;",
+        Target::Substrate { address_length: 32 },
+    );
 
     assert_eq!(
         first_error(ns.diagnostics),
         "‘external’: global variable cannot have visibility specifier"
     );
 
-    let ns = parse_and_resolve("uint constant x;", Target::Substrate);
+    let ns = parse_and_resolve("uint constant x;", Target::Substrate { address_length: 32 });
 
     assert_eq!(
         first_error(ns.diagnostics),
@@ -353,7 +359,7 @@ fn global_constants() {
 
     let ns = parse_and_resolve(
         "uint constant test = 5; contract test {}",
-        Target::Substrate,
+        Target::Substrate { address_length: 32 },
     );
 
     assert_eq!(