rjhdby
07/04/2018, 12:51 PMprivate fun getFile(name: String) {
val file = fopen(name, "wt")
if (file == null) throw Error("Cannot write file '$name'")
return file
private fun writeM4() {
val file = getFile("config.m4")
fputs(m4Content, file)
...
}
Compiler is fail with errors
dsl.kt:77:30: error: type mismatch: inferred type is Unit but CValuesRef<FILE /* = _IO_FILE */>? was expected
fputs(m4Content, file)
^
dsl.kt:86:16: error: type mismatch: inferred type is CPointer<FILE /* = _IO_FILE */>? but Unit was expected
return file
Why it does not infer automatically?russhwolf
07/04/2018, 1:05 PMgetFile()
. Return type always needs to be explicit in a function with a block body.olonho
07/04/2018, 1:05 PMrjhdby
07/04/2018, 1:10 PMolonho
07/04/2018, 1:12 PMrjhdby
07/04/2018, 1:15 PM