Skip to content

Commit 30cffdc

Browse files
committed
[Semantic] Lvalues are not arrays and updated tests
Fixes #41
1 parent 1f85cf3 commit 30cffdc

File tree

6 files changed

+69
-8
lines changed

6 files changed

+69
-8
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Dana Compiler CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
edge-and-extra-hard-cases:
9+
runs-on: ubuntu-latest
10+
env:
11+
LLVM_VERSION: "14"
12+
LLVM_CONFIG: "llvm-config-14"
13+
CC: "clang-14"
14+
CXX: "clang++-14"
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Install LLVM/Clang ${{ env.LLVM_VERSION }}
21+
shell: bash
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y \
25+
llvm-${LLVM_VERSION} llvm-${LLVM_VERSION}-dev \
26+
clang-${LLVM_VERSION} lld-${LLVM_VERSION} \
27+
make build-essential
28+
29+
# Sanity checks
30+
${LLVM_CONFIG} --version
31+
${LLVM_CONFIG} --cxxflags
32+
${CC} --version
33+
${CXX} --version
34+
35+
- name: Provide plain llvm-config on PATH
36+
shell: bash
37+
run: |
38+
# Your Makefile calls `llvm-config` (without suffix).
39+
# Create a symlink to llvm-config-14 so those backticks work.
40+
sudo ln -sf /usr/bin/llvm-config-14 /usr/local/bin/llvm-config
41+
echo "/usr/local/bin" >> $GITHUB_PATH
42+
which llvm-config
43+
llvm-config --version
44+
llvm-config --cxxflags
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: "3.10"
50+
51+
# test_compiler.py will run `make` in ./compiler, which now finds `llvm-config`
52+
- name: Run Edge and Extra-Hard Tests
53+
shell: bash
54+
env:
55+
LLVM_VERSION: ${{ env.LLVM_VERSION }}
56+
LLVM_CONFIG: ${{ env.LLVM_CONFIG }}
57+
CC: ${{ env.CC }}
58+
CXX: ${{ env.CXX }}
59+
run: |
60+
echo "Executing Python Compiler test script..."
61+
cd testing
62+
python test_edge_and_extra.py

compiler/ast.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,7 @@ class AssignStmt : public Stmt
17021702
// Now we are sure that it's a variable
17031703
lval->sem_analyze();
17041704

1705-
if (lval->isArrayType() && !lval->consideredStringVariable())
1705+
if (lval->isArrayType())
17061706
{
17071707
std::ostringstream oss;
17081708
oss << "Cannot assign to an array: " << lval->getName();

llvm/ast.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ class AssignStmt : public Stmt
16911691
// Now we are sure that it's a variable
16921692
lval->sem_analyze();
16931693

1694-
if (lval->isArrayType() && !lval->consideredStringVariable())
1694+
if (lval->isArrayType())
16951695
{
16961696
std::ostringstream oss;
16971697
oss << "Cannot assign to an array: " << lval->getName();

semantic/ast.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ class AssignStmt : public Stmt
967967
// Now we are sure that it's a variable
968968
lval->sem_analyze();
969969

970-
if (lval->isArrayType() && !lval->consideredStringVariable())
970+
if (lval->isArrayType())
971971
{
972972
std::ostringstream oss;
973973
oss << "Cannot assign to an array: " << lval->getName();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def main
2+
var s is byte [16]
3+
s := "hello" # should've written: strcpy: s, "hello\n"
4+
writeString: s

testing/string_error.dana

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)