Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some code under examples/clr can't be compiled #89

Open
retsyo opened this issue Aug 16, 2022 · 6 comments
Open

some code under examples/clr can't be compiled #89

retsyo opened this issue Aug 16, 2022 · 6 comments

Comments

@retsyo
Copy link
Contributor

retsyo commented Aug 16, 2022

I am using latest clone-and-built nim and winim package.

$ nim
Nim Compiler Version 1.7.1 [Windows: amd64]
Compiled at 2022-08-16
Copyright (c) 2006-2022 by Andreas Rumpf

$ nimble install wnim
Downloading https://github.com/khchen/wNim using git
  Verifying dependencies for [email protected]
   Warning: No .nimble or .nimble-link file found for C:\Users\Lenovo\.nimble\pkgs\inim-0.6.1
 Installing winim@>= 3.6.0
Downloading https://github.com/khchen/winim using git
  Verifying dependencies for [email protected]

#However, code_compiler.nim, simple_gui.nim, usage_demo2.nim can't be compiled
for example, for winim/examples/clr/simple_gui.nim, I get

$ nim c -r simple_gui.nim
Hint: used config file 'E:\msys64\home\USER\_nim\nim\config\nim.cfg' [Conf]
Hint: used config file 'E:\msys64\home\USER\_nim\nim\config\config.nims' [Conf]
...............................................................................................................................
E:\my_project\aardio\winform_miniexcel\simple_gui.nim(31, 51) Error: type mismatch: got <proc (sender: ptr IUnknown){.stdcall, locks: <unknown>.}>
but expected one of:
proc `[]`(s: mstring; i: int): char
  first type mismatch at position: 0
proc `[]`(s: mstring; i: mIndex): mstring
  first type mismatch at position: 0
proc `[]`(s: string; i: BackwardsIndex): char
  first type mismatch at position: 0
proc `[]`(s: var string; i: BackwardsIndex): var char
  first type mismatch at position: 0
proc `[]`(s: wstring; i: int): WCHAR
  first type mismatch at position: 0
proc `[]`(self: variant; name: string): variant
  first type mismatch at position: 0
proc `[]`(v: CLRVariant; i: SomeOrdinal): CLRVariant
  first type mismatch at position: 0
proc `[]`(v: CLRVariant; name: string): CLRVariant
  first type mismatch at position: 0
proc `[]`[I: Ordinal; T](a: T; i: I): T
  first type mismatch at position: 0
proc `[]`[Idx, T; U, V: Ordinal](a: array[Idx, T]; x: HSlice[U, V]): seq[T]
  first type mismatch at position: 0
proc `[]`[Idx, T](a: array[Idx, T]; i: BackwardsIndex): T
  first type mismatch at position: 0
proc `[]`[Idx, T](a: var array[Idx, T]; i: BackwardsIndex): var T
  first type mismatch at position: 0
proc `[]`[T, U: Ordinal](s: string; x: HSlice[T, U]): string
  first type mismatch at position: 0
proc `[]`[T, U](s: mstring; x: HSlice[T, U]): mstring
  first type mismatch at position: 0
proc `[]`[T, U](s: wstring; x: HSlice[T, U]): wstring
  first type mismatch at position: 0
proc `[]`[T: variant | SomeNumber | string](x: T): CLRVariant
  first type mismatch at position: 0
proc `[]`[T; U, V: Ordinal](s: openArray[T]; x: HSlice[U, V]): seq[T]
  first type mismatch at position: 0
proc `[]`[T](s: openArray[T]; i: BackwardsIndex): T
  first type mismatch at position: 0
proc `[]`[T](s: var openArray[T]; i: BackwardsIndex): var T
  first type mismatch at position: 0
proc `[]`[T](x: T; typ: CLRVariant): CLRVariant
  first type mismatch at position: 0
template `[]`(s: string; i: int): char
  first type mismatch at position: 0
template `[]`(self: com; name: string): variant
  first type mismatch at position: 0

expression: `[]`(eventHandler)

@khchen
Copy link
Owner

khchen commented Aug 17, 2022

Should be fixed.

@retsyo
Copy link
Contributor Author

retsyo commented Aug 17, 2022

not be fixed as expected

$ nim c -r usage_demo2.nim
Hint: used config file 'E:\msys64\home\Lenovo\_nim\nim\config\nim.cfg' [Conf]
Hint: used config file 'E:\msys64\home\Lenovo\_nim\nim\config\config.nims' [Conf]
................................................................................................................................
C:\Users\Lenovo\.nimble\pkgs\winim-3.9.0\winim\clr.nim(218, 37) template/generic instantiation of `fmt` from here
(1, 3) template/generic instantiation of `toHex` from here
E:\msys64\home\Lenovo\_nim\nim\lib\pure\strutils.nim(954, 13) Warning: target type is larger than source type [CastSizes]
C:\tmp\winim-master\examples\clr\usage_demo2.nim(111, 5) Hint: 'BindingFlags' should be: 'bindingFlags' [Name]
C:\tmp\winim-master\examples\clr\usage_demo2.nim(112, 5) Hint: 'Array' should be: 'array' [Name]
C:\tmp\winim-master\examples\clr\usage_demo2.nim(120, 5) Hint: 'TestClass' should be: 'testClass' [Name]
C:\tmp\winim-master\examples\clr\usage_demo2.nim(121, 5) Hint: 'TestClass2' should be: 'testClass2' [Name]
C:\tmp\winim-master\examples\clr\usage_demo2.nim(122, 5) Hint: 'MostDerived' should be: 'mostDerived' [Name]
C:\tmp\winim-master\examples\clr\usage_demo2.nim(160, 18) Error: type mismatch: got <array[0..1, int]>
but expected one of:
proc `[]`(s: mstring; i: int): char
  first type mismatch at position: 0
proc `[]`(s: mstring; i: mIndex): mstring
  first type mismatch at position: 0
proc `[]`(s: string; i: BackwardsIndex): char
  first type mismatch at position: 0
proc `[]`(s: var string; i: BackwardsIndex): var char
  first type mismatch at position: 0
proc `[]`(s: wstring; i: int): WCHAR
  first type mismatch at position: 0
proc `[]`(self: variant; name: string): variant
  first type mismatch at position: 0
proc `[]`(v: CLRVariant; i: SomeOrdinal): CLRVariant
  first type mismatch at position: 0
proc `[]`(v: CLRVariant; name: string): CLRVariant
  first type mismatch at position: 0
proc `[]`[I: Ordinal; T](a: T; i: I): T
  first type mismatch at position: 0
proc `[]`[Idx, T; U, V: Ordinal](a: array[Idx, T]; x: HSlice[U, V]): seq[T]
  first type mismatch at position: 0
proc `[]`[Idx, T](a: array[Idx, T]; i: BackwardsIndex): T
  first type mismatch at position: 0
proc `[]`[Idx, T](a: var array[Idx, T]; i: BackwardsIndex): var T
  first type mismatch at position: 0
proc `[]`[T, U: Ordinal](s: string; x: HSlice[T, U]): string
  first type mismatch at position: 0
proc `[]`[T, U](s: mstring; x: HSlice[T, U]): mstring
  first type mismatch at position: 0
proc `[]`[T, U](s: wstring; x: HSlice[T, U]): wstring
  first type mismatch at position: 0
proc `[]`[T: variant | SomeNumber | string | proc](x: T): CLRVariant
  first type mismatch at position: 0
proc `[]`[T; U, V: Ordinal](s: openArray[T]; x: HSlice[U, V]): seq[T]
  first type mismatch at position: 0
proc `[]`[T](s: openArray[T]; i: BackwardsIndex): T
  first type mismatch at position: 0
proc `[]`[T](s: var openArray[T]; i: BackwardsIndex): var T
  first type mismatch at position: 0
proc `[]`[T](x: T; typ: CLRVariant): CLRVariant
  first type mismatch at position: 0
template `[]`(s: string; i: int): char
  first type mismatch at position: 0
template `[]`(self: com; name: string): variant
  first type mismatch at position: 0

expression: `[]`([1, 2])

@retsyo
Copy link
Contributor Author

retsyo commented Aug 17, 2022

and "Remvoe annoying hints for symbol name in Nim Compiler 1.7.1 devel" in version 1.9.0 is not complete. For the rest can-be-compiled nim files, i.e., code_compiler.nim, misc_examples.nim, simple_gui.nim, splitter.nim, usage_demo1.nim and wpf.nim, we can find lots of Hints for every nim source with Nim 1.7.1 devel. For example

$ nim c -r code_compiler.nim
Hint: used config file 'E:\msys64\home\Lenovo\_nim\nim\config\nim.cfg' [Conf]
Hint: used config file 'E:\msys64\home\Lenovo\_nim\nim\config\config.nims' [Conf]
................................................................................................................................
C:\Users\Lenovo\.nimble\pkgs\winim-3.9.0\winim\clr.nim(218, 37) template/generic instantiation of `fmt` from here
(1, 3) template/generic instantiation of `toHex` from here
E:\msys64\home\Lenovo\_nim\nim\lib\pure\strutils.nim(954, 13) Warning: target type is larger than source type [CastSizes]
C:\tmp\winim-master\examples\clr\code_compiler.nim(10, 6) Hint: 'test_cs' should be: 'testCs' [Name]
C:\Users\Lenovo\.nimble\pkgs\winim-3.9.0\winim\clr.nim(742, 7) Hint: 'RuntimeHelp' should be: 'runtimeHelp' [Name]
C:\Users\Lenovo\.nimble\pkgs\winim-3.9.0\winim\clr.nim(737, 7) Hint: 'RuntimeHelp' should be: 'runtimeHelp' [Name]
C:\tmp\winim-master\examples\clr\code_compiler.nim(47, 6) Hint: 'test_vb' should be: 'testVb' [Name]
C:\tmp\winim-master\examples\clr\code_compiler.nim(68, 6) Hint: 'test_dll' should be: 'testDll' [Name]
C:\tmp\winim-master\examples\clr\code_compiler.nim(95, 7) Hint: 'TestClass' should be: 'testClass' [Name]

However, if I use nim 1.6.6 stable, not Hints is displayed when I compile the source

@retsyo
Copy link
Contributor Author

retsyo commented Aug 17, 2022

And there is an interesting thing, simple_gui.exe is killed soon everytime if I try to run it since McAfee says Real Protect-PENGSD5!949F4EBC7FAE is found - yes I know it is a false report.

However, splitter.exe and wpf.exe can run without any false virus report.

@khchen
Copy link
Owner

khchen commented Aug 17, 2022

OK, I became stupid after being a dad.
I add a small fix wihtout bump up the version.
Would you please try it again?

By the way, If some hints come from a file that I already added {.push hint[Name]: off.}, I can do nothing anymore.

@retsyo
Copy link
Contributor Author

retsyo commented Aug 18, 2022

A new born baby! Congratulations!

Btw. now all examples under clr directory can be compiled without problem. As for Hints, I posted it as https://forum.nim-lang.org/t/9382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants