You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ nim c -r test.nim
<html>
<head>
<title>Hello, world!</title>
</head>
<p>Hello, World!</p>
<body />
</html>
Expected Output
$ nim c -d:normal -r test.nim
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<p>Hello, World!</p>
</body>
</html>
Additional Information
$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-08-13
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: 4463a3c3d75daabfef52a139221f729e8af9e81e
active boot switches: -d:release -d:nimUseLinenoise
The text was updated successfully, but these errors were encountered:
I would argue that this might actually be expected behavior in the current version of Nim. The macros module defines a procedure called body which may be used to access the body of a proc. This causes multiple overloads to be bound to the symbol body. One of them has an untyped argument (the template defined above) and the other one has an argument of type NimNode (the proc defined in the macros module). According to the manual, multiple overloads of the same symbol might trigger the resolution of an untyped argument. This is why at the time of symbol resolution, the binding to the argument x from the template body is not yet available and x therefore still refers to the argument from the html template. As a result the paragraph node is added to the <html> node.
In order to check this hypothesis, we can add a proc definition proc body(x: int): int = discard at the top of the source code. Since this overload triggers the resolution of the argument, the same behaviour as above can be observed. Renaming the body template also works.
There has been previous discussion on changing this behavior in nim-lang/RFCs#402, although the initially proposed change to symbol resolution would not help in this case as far as I know.
Example
This was written to test some concepts, please don't read too much into the implementation.
Current Output
Expected Output
Additional Information
The text was updated successfully, but these errors were encountered: