Fixed const -> let bug #10
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
[0.4.6]
|
||||
|
||||
- Fixed bug in compiler where you were unable to assign a `const` value to
|
||||
a `let` variable
|
||||
|
||||
[0.4.5]
|
||||
|
||||
- Fixed issue where after clicking "Cancel" on the IC10 Editor, the side-by-side
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<ModMetadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Name>Slang</Name>
|
||||
<Author>JoeDiertay</Author>
|
||||
<Version>0.4.5</Version>
|
||||
<Version>0.4.6</Version>
|
||||
<Description>
|
||||
[h1]Slang: High-Level Programming for Stationeers[/h1]
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Slang
|
||||
{
|
||||
public const string PluginGuid = "com.biddydev.slang";
|
||||
public const string PluginName = "Slang";
|
||||
public const string PluginVersion = "0.4.5";
|
||||
public const string PluginVersion = "0.4.6";
|
||||
|
||||
private static Harmony? _harmony;
|
||||
|
||||
|
||||
2
rust_compiler/Cargo.lock
generated
2
rust_compiler/Cargo.lock
generated
@@ -930,7 +930,7 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
||||
|
||||
[[package]]
|
||||
name = "slang"
|
||||
version = "0.4.5"
|
||||
version = "0.4.6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "slang"
|
||||
version = "0.4.5"
|
||||
version = "0.4.6"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
|
||||
@@ -168,3 +168,28 @@ fn test_const_hash_expr() -> anyhow::Result<()> {
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_declaration_is_const() -> anyhow::Result<()> {
|
||||
let compiled = compile! {
|
||||
debug
|
||||
r#"
|
||||
const MAX = 100;
|
||||
|
||||
let max = MAX;
|
||||
"#
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
main:
|
||||
move r8 100
|
||||
"
|
||||
}
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -714,7 +714,12 @@ impl<'a> Compiler<'a> {
|
||||
|
||||
Operand::Register(VariableScope::TEMP_STACK_REGISTER)
|
||||
}
|
||||
VariableLocation::Constant(_) | VariableLocation::Device(_) => unreachable!(),
|
||||
VariableLocation::Constant(Literal::Number(num)) => Operand::Number(num.into()),
|
||||
VariableLocation::Constant(Literal::Boolean(b)) => {
|
||||
Operand::Number(Number::from(b).into())
|
||||
}
|
||||
VariableLocation::Device(_)
|
||||
| VariableLocation::Constant(Literal::String(_)) => unreachable!(),
|
||||
};
|
||||
self.emit_variable_assignment(&var_loc, src)?;
|
||||
(var_loc, None)
|
||||
|
||||
Reference in New Issue
Block a user