fix: module importing bug

This commit is contained in:
Shunsuke Shibayama 2023-03-14 06:30:38 +09:00
parent 65edef344c
commit e420185370
4 changed files with 19 additions and 17 deletions

16
Cargo.lock generated
View File

@ -253,8 +253,7 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "els"
version = "0.1.20-nightly.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ebd4f6abe5f42affe560a4d2d70240558406311aafa6f0d3dcc90d7c7edbdf1"
source = "git+https://github.com/erg-lang/erg?branch=main#75d838ee7bd1a0faced69ff52c8d19d8d2d5ac35"
dependencies = [
"erg_common",
"erg_compiler",
@ -275,8 +274,7 @@ dependencies = [
[[package]]
name = "erg_common"
version = "0.6.8-nightly.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3483797e9889dd1b54f858eb22540cfe6826e6bb188a129b60c93d68ff7ed2e3"
source = "git+https://github.com/erg-lang/erg?branch=main#75d838ee7bd1a0faced69ff52c8d19d8d2d5ac35"
dependencies = [
"backtrace-on-stack-overflow",
"hermit-abi",
@ -287,8 +285,7 @@ dependencies = [
[[package]]
name = "erg_compiler"
version = "0.6.8-nightly.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58a0ecbb398d305167c4aaa21aa76a1481fa5e606ecbe17a6a1ea3596bc4c083"
source = "git+https://github.com/erg-lang/erg?branch=main#75d838ee7bd1a0faced69ff52c8d19d8d2d5ac35"
dependencies = [
"erg_common",
"erg_parser",
@ -297,8 +294,7 @@ dependencies = [
[[package]]
name = "erg_parser"
version = "0.6.8-nightly.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0477961cfc3d14fc7564f7fddd23ab497426f62eb7238814b0b98ad7a6567c4a"
source = "git+https://github.com/erg-lang/erg?branch=main#75d838ee7bd1a0faced69ff52c8d19d8d2d5ac35"
dependencies = [
"erg_common",
"unicode-xid 0.2.4",
@ -622,9 +618,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.25"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5308e8208729c3e1504a6cfad0d5daacc4614c9a2e65d1ea312a34b5cb00fe84"
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
dependencies = [
"proc-macro2",
]

View File

@ -22,13 +22,13 @@ edition = "2021"
repository = "https://github.com/mtshiba/pylyzer"
[workspace.dependencies]
erg_common = { version = "0.6.8-nightly.0", features = ["py_compatible", "els"] }
erg_compiler = { version = "0.6.8-nightly.0", features = ["py_compatible", "els"] }
els = { version = "0.1.20-nightly.0", features = ["py_compatible"] }
# erg_common = { version = "0.6.8-nightly.0", features = ["py_compatible", "els"] }
# erg_compiler = { version = "0.6.8-nightly.0", features = ["py_compatible", "els"] }
# els = { version = "0.1.20-nightly.0", features = ["py_compatible"] }
rustpython-parser = "0.1.2"
# erg_compiler = { git = "https://github.com/erg-lang/erg", branch = "main", features = ["py_compatible", "els"] }
# erg_common = { git = "https://github.com/erg-lang/erg", branch = "main", features = ["py_compatible", "els"] }
# els = { git = "https://github.com/erg-lang/erg", branch = "main", features = ["py_compatible"] }
erg_compiler = { git = "https://github.com/erg-lang/erg", branch = "main", features = ["py_compatible", "els"] }
erg_common = { git = "https://github.com/erg-lang/erg", branch = "main", features = ["py_compatible", "els"] }
els = { git = "https://github.com/erg-lang/erg", branch = "main", features = ["py_compatible"] }
[features]
debug = ["erg_compiler/debug", "erg_common/debug", "py2erg/debug"]

View File

@ -1629,7 +1629,12 @@ impl ASTConverter {
self.convert_ident("__import__".to_string(), stmt.location),
));
// from . import foo ==> import "./foo"
let cont = format!("\"{}\"", module.unwrap_or_else(|| names[0].symbol.clone()));
let cont = format!(
"\"{}\"",
module
.unwrap_or_else(|| names[0].symbol.clone())
.replace('.', "/")
);
let mod_name = Expr::Literal(Literal::new(Token::new(
TokenKind::StrLit,
cont,

View File

@ -3,6 +3,7 @@ import random
from random import randint as rdi
from datetime import datetime, timedelta
import datetime as dt
from http.client import HTTPResponse
i = random.randint(0, 1)
print(i + 1)