mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 12:14:43 +00:00
Revert "Fix a socket connection problem"
This reverts commit 962569d5a0
.
This commit is contained in:
parent
962569d5a0
commit
4579c86414
3 changed files with 15 additions and 7 deletions
|
@ -252,7 +252,10 @@ impl<Checker: BuildRunnable> Server<Checker> {
|
||||||
// NG: f(proc:= i: T): U -> ...
|
// NG: f(proc:= i: T): U -> ...
|
||||||
// OK: f proc:= (i: T): U -> ...
|
// OK: f proc:= (i: T): U -> ...
|
||||||
let (name, col_begin) = if arg_is_lambda {
|
let (name, col_begin) = if arg_is_lambda {
|
||||||
(format!(" {name}"), col_begin.saturating_sub(1))
|
(
|
||||||
|
format!(" {name}"),
|
||||||
|
col_begin.saturating_sub(1),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
(name.to_string(), col_begin)
|
(name.to_string(), col_begin)
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,8 +11,8 @@ use erg_common::python_util::BUILTIN_PYTHON_MODS;
|
||||||
use erg_common::set::Set;
|
use erg_common::set::Set;
|
||||||
use erg_common::traits::{Locational, Stream};
|
use erg_common::traits::{Locational, Stream};
|
||||||
use erg_common::vis::Visibility;
|
use erg_common::vis::Visibility;
|
||||||
use erg_common::Str;
|
|
||||||
use erg_common::{enum_unwrap, get_hash, log, set};
|
use erg_common::{enum_unwrap, get_hash, log, set};
|
||||||
|
use erg_common::Str;
|
||||||
|
|
||||||
use ast::{Decorator, DefId, Identifier, OperationKind, SimpleTypeSpec, VarName};
|
use ast::{Decorator, DefId, Identifier, OperationKind, SimpleTypeSpec, VarName};
|
||||||
use erg_parser::ast::{self, ConstIdentifier};
|
use erg_parser::ast::{self, ConstIdentifier};
|
||||||
|
|
15
src/dummy.rs
15
src/dummy.rs
|
@ -209,9 +209,14 @@ impl DummyVM {
|
||||||
|
|
||||||
fn find_available_port() -> u16 {
|
fn find_available_port() -> u16 {
|
||||||
const DEFAULT_PORT: u16 = 8736;
|
const DEFAULT_PORT: u16 = 8736;
|
||||||
let mut port = DEFAULT_PORT;
|
TcpListener::bind(SocketAddrV4::new(Ipv4Addr::LOCALHOST, DEFAULT_PORT))
|
||||||
while TcpListener::bind(SocketAddrV4::new(Ipv4Addr::LOCALHOST, port)).is_err() {
|
.is_ok()
|
||||||
port += 1;
|
.then_some(DEFAULT_PORT)
|
||||||
}
|
.unwrap_or_else(|| {
|
||||||
port
|
let socket = SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0);
|
||||||
|
TcpListener::bind(socket)
|
||||||
|
.and_then(|listener| listener.local_addr())
|
||||||
|
.map(|sock_addr| sock_addr.port())
|
||||||
|
.expect("No free port found.")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue