Commit 316e4d8b authored by Tom Niget's avatar Tom Niget

Fix some generic things

parent e84a9530
......@@ -11,6 +11,12 @@ class Thing(Generic[T]):
x: T
def f(x: T):
pass
if __name__ == "__main__":
a = Thing[int](1)
b = Thing[str]("abc")
......
......@@ -43,10 +43,6 @@ def server_loop(sockfd, filepath):
fork(lambda: handle_connection(connfd, filepath))
def server_loops(sockfd, filepath):
for i in range(20):
fork(lambda: server_loop(sockfd, filepath))
if __name__ == "__main__":
if len(sys.argv) > 2:
print("Usage: webserver [ filepath ]")
......@@ -57,4 +53,4 @@ if __name__ == "__main__":
sockfd = create_listening_socket(PORT)
server_loops(sockfd, filepath)
\ No newline at end of file
server_loop(sockfd, filepath)
\ No newline at end of file
......@@ -43,14 +43,10 @@ def server_loop(sockfd):
fork(lambda: handle_connection(connfd))
def server_loops(sockfd):
for i in range(20):
fork(lambda: server_loop(sockfd))
if __name__ == "__main__":
print("Serving on port", PORT)
print()
sockfd = create_listening_socket(PORT)
server_loops(sockfd)
server_loop(sockfd)
......@@ -278,7 +278,7 @@ class ExpressionVisitor(NodeVisitor):
yield "{}"
def visit_Subscript(self, node: ast.Subscript) -> Iterable[str]:
if isinstance(node.type.type_object, MonomorphizedUserType):
if isinstance(node.type, TypeType) and isinstance(node.type.type_object, MonomorphizedUserType):
yield node.type.type_object.name
return
yield from self.prec("[]").visit(node.value)
......
......@@ -280,7 +280,7 @@ class ScoperBlockVisitor(ScoperVisitor):
else:
# not generic
ctype = self.process_class_ast(UserType(node.name), node, bases_after)
cttype = TypeType(OurGenericType)
cttype = TypeType(ctype)
self.scope.vars[node.name] = VarDecl(VarKind.LOCAL, cttype)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment