Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/sema/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,22 +309,31 @@ pub fn eval_const_rational(
var_no,
..
} => {
let expr = ns.contracts[*contract_no].variables[*var_no]
if let Some(init) = ns.contracts[*contract_no].variables[*var_no]
.initializer
.as_ref()
.unwrap()
.clone();

eval_const_rational(&expr, ns)
{
eval_const_rational(&init.clone(), ns)
} else {
Err(Diagnostic::error(
expr.loc(),
"constant variable has no value".to_string(),
))
}
}
Expression::ConstantVariable {
contract_no: None,
var_no,
..
} => {
let expr = ns.constants[*var_no].initializer.as_ref().unwrap().clone();

eval_const_rational(&expr, ns)
if let Some(init) = ns.constants[*var_no].initializer.as_ref() {
eval_const_rational(&init.clone(), ns)
} else {
Err(Diagnostic::error(
expr.loc(),
"constant variable has no value".to_string(),
))
}
}
_ => Err(Diagnostic::error(
expr.loc(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contract C {
uint public constant Y = 0e1000;
constructor(int[Y - .1] memory w) {}
}

// ---- Expect: diagnostics ----
// error: 2:30-36: exponent '1000' too large