Converting a call chain and assignment attempt to Void safety

2 messages Options
Embed this post
Permalink
peter7723

Converting a call chain and assignment attempt to Void safety

Reply Threaded More More options
Print post
Permalink
I have the following original code:
ws ?= workbook.worksheets.item (as_sys_string("Processed"))

I attempted to translate it as:
   if attached workbook as a_wb and then
      attached a_wb.worksheets as a_wshs and then
      attached a_wshs.item (as_sys_string("Processed")) as a_wshs_item
   then
      ws := a_wshs_item
   end

where the locals are
   workbook: detachable EXCEL_WORKBOOK
   ws: detachable EXCEL_WORKSHEET

and get the error below.

I did attempt to include the target type, but the syntaxes tried fail (e.g. "... as a_wshs_item: EXCEL_WORKSHEET").

The error is
VJAR: Source of assignment does not conform to target. CONFIGURATION_DIALOG.select_weather_data_file (root_cluster) 103, 6
Error code: VJAR

Type error: source of assignment does not conform to target.
What to do: make sure that type of source (right-hand side)
  conforms (in the sense of inheritance rule) to type of target.

Class: CONFIGURATION_DIALOG
Feature: select_weather_data_file
Target name: ws
Target type: detachable EXCEL_WORKSHEET
Source type: attached SYSTEM_OBJECT
Line: 103
 attached a_wshs.item (as_sys_string("Processed")) as a_wshs_item then
->          ws := a_wshs_item
        end


Emmanuel Stapf

RE: Converting a call chain and assignment attempt to Void safety

Reply Threaded More More options
Print post
Permalink
> I did attempt to include the target type, but the syntaxes tried fail
> (e.g. "... as a_wshs_item: EXCEL_WORKSHEET").

The syntax is:

        attached {EXPECTED_TYPE} expression as object_test_local

Regards,
Manu


------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------